JQuery.delegate () does not work when loading and changing Data events

Can someone enlighten me in the jQuery delegate which events are being processed and which are not. The following code does not work

$("#browser").delegate( ".photo", {
    "load": function(e) {
        alert("photo loaded");
    }
});

but the following code works

$(".photo").load( function(e) {
    alert("photo loaded");
} );

I am also trying to delegate the changeData event to a class that also does not work

$("#browser").delegate( ".thumbnail", {
    "changeData": function(e, prop, value) {
        alert( prop + " = " + value );
    }
});

but the following code works

$(".thumbnail").bind( "changeData", function(e, prop, value) {
    alert( prop + " = " + value );
}
+5
source share
3 answers

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 these events because they do not bubble.

+11
source

These events do not bubble, so they cannot be used with liveor delegate.

+6
source

jQuery, .on() .delegate() .live(), ,

// wrong
jQuery(selector).on('load', 'img', myFunc)

:

jQuery(selector).find('img').on('load', myFunc)
0

All Articles