Can someone enlighten me on the jQuery delegate, what events are handled and what aren\'t. The follow code doesn\'t work
$(\"#browser\").delegate( \".photo\"
These events do not bubble, so they cannot be used with live
or delegate
.
Not:
$("#browser").delegate( ".photo", {
"load": function(e) {
alert("photo loaded");
}
});
But:
$("#browser").delegate( ".photo", "load",
function(e) {
alert("photo loaded");
});
And you cannot use live and delegate with those events, because they don't bubble.
For newer versions of jQuery, where the .on()
method is favored before the .delegate()
or .live()
methods, it won't work in this way, too
// wrong
jQuery(selector).on('load', 'img', myFunc)
because the load event does not bubble
make it like this
jQuery(selector).find('img').on('load', myFunc)