I'm using GWT and GwtQuery to create a javascript file to track some analytics.
I want to bind handlers to elements with certain data- attributes, they may or may not be present onModuleLoad().
I tried:
$(document).on("click", "body * img[data-im-lookingfor]", new Function() {...});
$(document).on("click", "img[data-im-lookingfor]", new Function() {...});
$(GQuery.document).on("click", "img", new Function() {...});
But it will not bind to anything. Looking the source code for .on, when a selector is passed it will create a delegate behind the scenes.
What does work, but only for elements present onModuleLoad():
$("img[data-im-lookingfor]").on("click", new Function() {...});
I'm looking for a way to bind to all current and future elements, whether created in plain javascript or inside the GWT/GQuery Module.
Any suggestions.
Thanks, --B