I'm trying to load images dynamically after an Ajax call. Then I want to detect once those images have finished loading and call a handler. I need this to be pure javascript and I need to not bind a listener directly to the image, I want to bind to the window/dom and delegate events.
I've tried a bunch of different examples online and none seem to work with the load event.
window.addEventListener("load", function(e) {
console.log("in");
var target=e.target;
if (target.classList && target.classList.contains('target-class')) {
handler.call(target, e);
}
});
This is what I have now and it simply doesn't work. It doesn't even fire the console log when the images are appended and loaded.