You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

Triggering a tooltip on click event Created Jan 17, 2010

This thread is solved

Views: 7469     Replies: 10     Last reply Dec 28, 2010  
You must login first before you can use this feature

gthiruva

Posts: 1

Registered:
Jan 17, 2010

Triggering a tooltip on click event

Posted: Jan 17, 2010

I just downloaded jQuery Tools today and thought I'd try and do some tooltip magic. I'm trying to register a tooltip to pop up whenever the user clicks on a mailto: link. But so far, it seems to want to pop up by hovering only. I tried messing around with the events:{} options to no avail. Anyone have any thoughts? Here's my registration code:


$('a[href^=mailto:]').live('click', function(clickEvent){clickEvent.preventDefault();});
$('a[href^=mailto:]').tooltip({
	// place tooltip on the right edge
	position: "center right",
 
	// a little tweaking of the position
	offset: [-2, 10],
 
	// use the built-in fadeIn/fadeOut effect
	effect: "fade",
 
	// custom opacity setting
	opacity: 0.7,
 
	// use this single tooltip element
	tip: '.tooltip',
    
    event:{def:'click'}
});

spirelli

Posts: 4

Registered:
Jan 12, 2010

» Triggering a tooltip on click event

Posted: Jan 19, 2010

Reply to: Triggering a tooltip on click event, from gthiruva
I also would like the tooltip to appear on click, and diappear on clicking outside (just moving outside would also be ok). What can I do, not being a programmer?

Many thanks.

kenan

Posts: 3

Registered:
Mar 4, 2010

» Triggering a tooltip on click event

Posted: Mar 4, 2010

Reply to: Triggering a tooltip on click event, from gthiruva
Is there a mechanism to initiate the tooltip on a onClick event.
Thanks.

kenan

Posts: 3

Registered:
Mar 4, 2010

» » Triggering a tooltip on click event

Posted: Mar 4, 2010

Reply to: » Triggering a tooltip on click event, from kenan
My tooltip is triggered by a span element. I tried to set it to the following, but still the mouseover behavior is dominating.

$("#spanelement").tooltip({
events:{span:'click, mouseout'},
tip: '#tip',
offset: [2, 2],
effect: 'slide' ,
delay: 300,
onBeforeShow:function() {resetToolTipContent(); }
// add dynamic plugin
}).dynamic({
// customized configuration on bottom edge
bottom: {
// slide down,up, right and left , for now right.
direction: 'right',
// bounce back when closed
bounce: true
}
});

triprotic

Posts: 1

Registered:
Mar 9, 2010

» » » Triggering a tooltip on click event

Posted: Mar 9, 2010

Reply to: » » Triggering a tooltip on click event, from kenan
I've found the only way to get around this bug is to individual specify a unique hover item and tool tip item.

Instead of a generic call e.g.


$("#form:input").tooltip({ 
    events: {def:"click,click"}, 
    position: "center right", 
    offset: [0, 0], opacity: 1, 
    tip: '.tooltip'
}); 

Use specific calls for items:


$("#item1").tooltip({
    events: {def:"click,click"},
    position: "center right",
    offset: [0, 0],
    opacity: 1,
    tip: '#tooltip1'
}); 
$("#item2").tooltip({
    events: {def:"click,click"},
    position: "center right",
    offset: [0, 0],
    opacity: 1,
    tip: '#tooltip2'
}); 
$("#item3").tooltip({
    events: {def:"click,click"},
    position: "center right",
    offset: [0, 0],
    opacity: 1,
    tip: '#tooltip3'
}); 

Not a great work around, but if you are generating things on the fly with PHP you should be able to generate all the references easily.

sLQ

Posts: 1

Registered:
Apr 15, 2010

» » » » Triggering a tooltip on click event

Posted: Apr 16, 2010

Reply to: » » » Triggering a tooltip on click event, from triprotic
Here is the solution to get tooltip correctly working onClick event:


<script>
$(".someClass").tooltip({ 

   //the trick is to set it like this
   events: {def: "click,mouseout"},

   //the tip content
   tip: '#elementToBeShown', 

   //the effect
   effect: 'slide'
});
</script>


there is also no problem to generate dynamic tooltips with php, all you need to do is to generate element that will be shown(must be uniqe) and according to it java code :-) the code below should be useful:


<?php 
echo "<script>
"; 
    foreach($userList as $user => $userData){ 
        echo "$(".tp-{$userData['username']}")"
        . ".tooltip({ events: {def: "click, mouseout"}, " 
        . "tip: '#tp-{$userData['username']}', effect: 'slide'}); 
";
    } 
echo "</script>";
?>

there should be " with slash on the front instead of single " inside echo function but here slashes are stripped out while posting i guess ;/

hope this helps to someone...

cyrotello
Help save a life. Your own.

Posts: 2

Registered:
Jul 21, 2010

» » » » » Triggering a tooltip on click event

Posted: Jul 21, 2010

Reply to: » » » » Triggering a tooltip on click event, from sLQ
...had the same issue, and this answer solved it.

But what if you'd like to use only one of the arguments?

def's default is "mouseenter,mouseleave". If you don't want the 'mouseleave' argument (you want to close the tooltip using the api (http://flowplayer.org/tools/tooltip/index.html#api) ), use a zero-length string in place of the mouseleave argument:
events: { def: "mouseenter,''" }

...or handle the entire showing and hiding of the tooltip using the api:
events: { def: "'',''" }

Took some quality time to figure it out, but should save you some.

Ramin

Posts: 4

Registered:
Jun 16, 2010

Tooltip click lacking

Posted: Jul 29, 2010

Reply to: » » » » » Triggering a tooltip on click event, from cyrotello
Although this tooltip library is really nice and functions well with the current default behaviors, it seems a bit lacking when it comes to customizing it (for better or for worse). It seems like it wasn't mean to be triggered with a click, as tooltips generally display when you hover over something.

Of course there are ways to get around this by defining custom code in the callbacks, etc. but that sort of defeats the purpose of using this nice lightweight library. I may put together my own tooltip library based on this one or extend this one with a plugin or something to handle clicks properly. Clicks to trigger both the tooltip as well as hide it when clicking outside of it.