Monday, October 16, 2017

GQuery.on() and future elements created outside of GWT.

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

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment