Tuesday, March 4, 2014

Re: Problems using native JavaScript library (Snap)



On Tuesday, March 4, 2014 5:55:35 PM UTC+1, Jens wrote:
 
   When injecting your script, make sure you inject it into the top window (setWindow(ScriptInjector.TOP_WINDOW)), then reference your globals within $wnd.
How exactly would you modify the injection code above?

Ehh...by calling setWindow() as already mentioned?

I was wondering which class setWindow belongs to. It's FromString. 

(How does setWindow influence where the code gets injected?)

By default ScriptInjector uses the JS object "window" to inject your code. When inside an iframe "window" points to the iframe window, so code gets injected into the iframe.

I was calling the inject code from within the constructor of my "SnapWidget", which is a Widget.
 
When you tell ScriptInjector to inject into the top window it will use GWT's special JS variable "$wnd" which always points to the top level window.

Ok!
 
Magnus

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" 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 http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment