Side navigation
#6880 closed enhancement (duplicate)
Opened August 06, 2010 03:54AM UTC
Closed January 02, 2011 12:46AM UTC
Last modified January 02, 2011 12:46AM UTC
Add compatibility to be able to 'trigger' mouseleave/mouseenter special events w/ bubbling
Reported by: | kingjeffrery | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.5 |
Component: | event | Version: | 1.4.4 |
Keywords: | trigger mouseenter mouseleave live delegate | Cc: | |
Blocked by: | Blocking: |
Description
trigger('mouseenter') and trigger('mouseleave') properly triggers events associated with bind(), but not do not trigger events associated with live() or delegate(). Every other event triggers all three.
There are a handful of tickets reporting this as it relates to live(), but there is nothing reporting it for the delegate().
Example code:
HTML:
<div class="example"><span>Example</span></div>
JS:
$('.example span').bind('mouseenter', function(){ alert('live'); });
$('.example span').live('mouseenter', function(){ alert('live'); });
$('.example').delegate('span', 'mouseenter', function(){ alert('delegate'); });
$('.example span').trigger('mouseenter');
Only the 'live' alert will fire.
Attachments (0)
Change History (12)
Changed August 06, 2010 06:43AM UTC by comment:1
Changed August 06, 2010 07:31PM UTC by comment:2
An example page, demonstrating .trigger() work with every event other than mouseenter, mouseleave and hover can be found here: http://test.kingdesk.com/jquery/bind_live_delegate.php
Changed August 07, 2010 03:26AM UTC by comment:3
Since mouseenter and mouseleave don't bubble, any live or delegate attempt higher up the tree wouldn't work. However, a mouseover or mouseout event should work there.
http://www.quirksmode.org/dom/events/mouseover.html
Does that explain the behavior you're reporting? If so, do we just need to explicitly document that?
Changed August 11, 2010 04:32PM UTC by comment:4
@dmethvin
That would explain things if the mouseenter and mouseleave events were unsupported for live and delegate; but they are supported. The non-bubbling has been overcome for these events when it comes to checking its ancestors for delegated events. But in this case, .trigger() will trigger every event (whether bubbling or not, whether live, deleate or bind) except for mouseenter and mouseleave (and hover which depends on these two events).
Stated another way... I can trigger the mouseenter event that is delegated to an ancestor by moving my mouse over it. I can not trigger the same event with the .trigger() method. If the problem is simply "the event doesn't bubble, so it is not supported", I should not be able to trigger the event physically. But the lack of bubbling has been overcome for live and delegate, and is thus supported in those methods. It is therefore a significant inconsistency to not support it with the .trigger() method.
Changed October 25, 2010 07:06AM UTC by comment:5
milestone: | 1.4.3 → 1.5 |
---|---|
priority: | → high |
status: | new → open |
summary: | trigger('mouseenter') and trigger('mouseleave') do not trigger events associated with bind() or delegate() → Add compatibility to be able to 'trigger' mouseleave/mouseenter special events w/ bubbling |
type: | bug → enhancement |
Yea, it seems like an inconsistency, I agree, to not allow these to be triggered and then force the bubble. I think though, it was not unintentional, at least at the time they became supported in delegate and live, that they were not compatible with trigger. I'm not sure exactly why, but it doesn't seem like it's something they'd forget.
I'll push this in as a high priority feature request, since jQuery doesn't really document these special events being triggerable in either direction.
Until then, you can always trigger the event directly on the container and set the event.target to what you need... not beautiful, but would work in the meantime.
Changed October 25, 2010 07:49AM UTC by comment:6
resolution: | → duplicate |
---|---|
status: | open → closed |
Setting this as a dupe
Changed October 25, 2010 07:50AM UTC by comment:8
resolution: | duplicate |
---|---|
status: | closed → reopened |
Was not a dupe. Sorry. Will look more closely next time. But related to 5884, slightly.
Changed November 22, 2010 07:07AM UTC by comment:10
status: | reopened → open |
---|---|
version: | 1.4.2 → 1.4.4 |
Changed January 02, 2011 12:46AM UTC by comment:11
resolution: | → duplicate |
---|---|
status: | open → closed |
Changed January 02, 2011 12:46AM UTC by comment:12
Duplicate of #6514.
This – of course – also means that .trigger('hover') does not trigger .live() or .delegate() events (since hover is mapped to mouseenter and mouseleave).