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

Your preferred username that is used when logging in.

Tooltip trigger object Created Jun 9, 2009

This thread is solved

Views: 1970     Replies: 10     Last reply Jun 12, 2009  
You must login first before you can use this feature

Simon
http://www.demodia.com/

Posts: 8

Registered:
Jun 9, 2009

Tooltip trigger object

Posted: Jun 9, 2009

I am trying to set up a tooltip to show whenever a user enters a table. I have the jQuery initialisation like so:

$(".my_table").tooltip();

My hope is that when someone mouses-over the table, the tooltip appears above the top-middle of the overall table.

However, in reality what is happening is that the trigger event is not being fired on the expected element. Very often what I see is that it is fired on one of the TD elements, so the tooltip appears in seemingly random places across my table.

Is this the correct operation, or is this a bug? Either way, any suggestions how I can work around it?

degenerate

Posts: 156

Registered:
Sep 19, 2008

» Tooltip trigger object

Posted: Jun 9, 2009

Reply to: Tooltip trigger object, from sharvey
I would put the entire table into a div and trigger on the div instead. It sounds like unexpected behavior, but not necessarily a bug because I don't think the devs expected you to trigger on a table itself.

Simon
http://www.demodia.com/

Posts: 8

Registered:
Jun 9, 2009

» » Tooltip trigger object

Posted: Jun 10, 2009

Reply to: » Tooltip trigger object, from degenerate
Unfortunately I have tried that and it always seems to trigger on the top most element of the DOM hierarchy that is moused-over.

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1672

Registered:
Nov 16, 2007

» Tooltip trigger object

Posted: Jun 10, 2009

Reply to: Tooltip trigger object, from sharvey
do you have a page to look at? there should be no problems.

Simon
http://www.demodia.com/

Posts: 8

Registered:
Jun 9, 2009

» » Tooltip trigger object

Posted: Jun 10, 2009

Reply to: » Tooltip trigger object, from tipiirai
Sure, i've put up a sample page here showing the problem.

http://dev.demodia.com/jquery-tools/trigger-test.html

The tooltip shows the element that the tooltip is being triggered by. In this example, I always want the tooltip to appear centered above the top of the main table.

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1672

Registered:
Nov 16, 2007

» » » Tooltip trigger object

Posted: Jun 10, 2009

Reply to: » » Tooltip trigger object, from sharvey
ok. yes I can see that now. This is a bug and is now on my todo-list. Thanks!

Simon
http://www.demodia.com/

Posts: 8

Registered:
Jun 9, 2009

» » » » Tooltip trigger object

Posted: Jun 10, 2009

Reply to: » » » Tooltip trigger object, from tipiirai
Not sure whether or not this is a good solution, but I have found that I can cure the problem by modifying the bind function as below:

trigger.bind(isInput ? "focus" : "mouseover", function(e) {
	e.target = $(this)[0];  // - added this line
	self.show(e);  
	tip.hover(function() { self.show(); }, function() { self.hide(); });
});

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1672

Registered:
Nov 16, 2007

» » » » » Tooltip trigger object

Posted: Jun 10, 2009

Reply to: » » » » Tooltip trigger object, from sharvey
looks like an elegant solution to me. thanks! I guess this can be shortened by simply setting


e.target = this;

Simon
http://www.demodia.com/

Posts: 8

Registered:
Jun 9, 2009

» » » » » » Tooltip trigger object

Posted: Jun 10, 2009

Reply to: » » » » » Tooltip trigger object, from tipiirai
I seem to recall trying just


e.target = this;

but if I remember correctly it threw an error as "this" is a jQuery object, where as e.target is expecting a DOM member.

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1672

Registered:
Nov 16, 2007

» » » » » » » Tooltip trigger object

Posted: Jun 11, 2009

Reply to: » » » » » » Tooltip trigger object, from sharvey
Haven't tried it actually but inside jQuery events this variable references a DOM object and many times it needs to be converted to a jQuery object.

writing


$(this)[0]

essentially means transforming DOM object to a jQuery object and then do the vice versa.

But you still may be right. I need to test this.

Thanks!

EDIT: just noticed that the simple e.target = this; works.

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1672

Registered:
Nov 16, 2007

» » » » » » » » Tooltip trigger object

Posted: Jun 12, 2009

Reply to: » » » » » » » Tooltip trigger object, from tipiirai
Ok. This change is now in the latest release which was just published.