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

Your preferred username that is used when logging in.

Solution to multiple events triggered by children elements Created Nov 11, 2009

This thread is solved

Views: 1090     Replies: 2     Last reply Feb 1, 2010  
You must login first before you can use this feature

joshm

Posts: 2

Registered:
Nov 11, 2009

Solution to multiple events triggered by children elements

Posted: Nov 11, 2009

If you are getting multiple 'onShow' and 'onHide' events being triggered with your tooltip, this might help. Use mouseenter and mouseleave as your tooltop events:


...
events: { 
  def: "mouseenter,mouseleave", //  for an element 
  input: "focus,blur", // for all input elements 
  widget: "focus mouseover,blur mouseout", // select, checkbox, radio, button 
  tooltip: "mouseenter,mouseleave" // the tooltip element 
},
...
instead of the default "mouseover, mouseout" events. This prevent the events from being triggered by the mouse moving over element descendants.

My situation was a tooltip attached to a div with children span elements in it. There were multiple 'onShow' events because an event was triggered when the mouse moved over any of the children spans. This change prevents the events from being triggered by children. This gives me one event when the mouse enters the parent div and one 'onHide' when it leaves, the behavior I want.

Just in case anyone else wants the same. Might be nice for the event documentation too, it's a good reason for wanting to change them.

Thanks for the great library.
Josh

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

Posts: 1867

Registered:
Nov 16, 2007

» Solution to multiple events triggered by children elements

Posted: Nov 14, 2009

Reply to: Solution to multiple events triggered by children elements, from joshm
noticed your tweet on this issue. sounds like a proper modification for the tool. I'll test this and add to the next release.

Much appreciated! thanks.

alexneth

Posts: 2

Registered:
Jan 29, 2010

» » Solution to multiple events triggered by children elements

Posted: Feb 1, 2010

Reply to: » Solution to multiple events triggered by children elements, from tipiirai
There is more to this problem. Inside event handlers, getTrigger() returns the element that the mouse entered over instead of what seems more appropriate, which is the outer element that the tooltip is attached to. This problem I believe also occasionally causes tooltips to be mis-positioned when it uses the inner object for positioning. I have seen this happen a number of times.

I worked around the first problem by using jQuery's .nearest method to crawl back up to my main element, because I store data on that element.