jquery - Why won't .live() work with my custom event, but .bind() will? -
i'm thinking it's bug, of 1.4.2, .live()
supposed support custom events. here's quick little demo: http://jsbin.com/erofi/edit
is bug, or doing wrong triggers?
.live()
must used on selector. whether event target element matches selector string checked @ event time. hinted @ in doc ‘caveats’:
dom traversal methods not supported finding elements send .live(). rather, .live() method should called directly after selector, in example above.
$(document)
isn't selector. if @ $(document).selector
, remembered selector string live()
uses matching, empty string, hence live()
not working.
since selectors match elements, can't live
-bind against document
. again, since document
never changes, there no need to: normal binding fine.
(this unfortunate api design. should have been $.live('selector', 'event', function() {});
imo. $('selector').live()
makes unclear it's doing. , there should have been error when call live()
on wrapper without selector.)
Comments
Post a Comment