Opened 12 years ago
Closed 12 years ago
#9169 closed bug (wontfix)
.live fails to call handler for DOMNodeInserted
Reported by: | Owned by: | Rick Waldron | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | event | Version: | 1.6 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
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 (6)
comment:1 Changed 12 years ago by
Component: | unfiled → event |
---|---|
Owner: | set to Rick Waldron |
Priority: | undecided → low |
Status: | new → assigned |
comment:2 Changed 12 years ago by
comment:3 Changed 12 years ago by
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 12 years ago by
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 12 years ago by
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 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
binding a live listener to an actual selector works....
http://jsfiddle.net/rwaldron/4tVAx/3/