Bug Tracker

Modify

Ticket #9169 (closed bug: wontfix)

Opened 2 years ago

Last modified 2 years ago

.live fails to call handler for DOMNodeInserted

Reported by: augustus.kling@… Owned by: rwaldron
Priority: low Milestone: 1.next
Component: event Version: 1.6
Keywords: Cc:
Blocking: Blocked by:

Description

When an event handler for the DOMNodeInserted event is attached to the document node using bind, the handler gets called as expected. However when live is used to bind the handler, the handler is not called.

According to the documentation of live, it should work for “custom events as well as all JavaScript events that bubble”. DOMNodeInserted bubbles according to  http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted and should therefore be supported using live.

See  http://jsfiddle.net/4tVAx/1/ for a demo. Clicking the button should give 2 lines in the console. One starting with “bind”, the other starting with “live”.

Verified with Firefox 4.0.1, Chromium 11.0.696.57 (82915) on Ubuntu 11.04 and jQuery versions 1.4.4, 1.5.2, 1.6.

Change History

comment:1 Changed 2 years ago by rwaldron

  • Owner set to rwaldron
  • Priority changed from undecided to low
  • Status changed from new to assigned
  • Component changed from unfiled to event

comment:2 Changed 2 years ago by rwaldron

binding a live listener to an actual selector works....

 http://jsfiddle.net/rwaldron/4tVAx/3/

comment:3 Changed 2 years ago by augustus.kling@…

That allows for using $('html').live instead of $(document).live.

In the meantime I noted that $(document).live also fails for other event types such as click, too. Is it possible that live only works for element nodes?

Probably the initial bug description is then misleading when it names a specific event type. It seems events do bubble up to document (as expected) when using bind, but not not when using live.

comment:4 Changed 2 years ago by timmywil

It doesn't really make sense to call $(document).live since live works by allowing the event to bubble up to the document and then distributing the event to the appropriate targets. There's no need for live in that case. It sounds like what you really want is to bind to the document.

comment:5 Changed 2 years ago by rwaldron

I guess I should've noted in my comment that I wasn't implying a fix, but more that I only had time to try that example that I provided. More importantly, I wanted to confirm the validity of this ticket before proceeding. The docs say "Attach a handler to the event for all elements which match the current selector, now and in the future"... the keyword being "selector".

comment:6 Changed 2 years ago by rwaldron

  • Status changed from assigned to closed
  • Resolution set to wontfix

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.