tags:

views:

151

answers:

2

The following gwt jsni method code only "works" when I have firebug open, I presume because its slowing down the page rendering long enough for the external js files to finish loading.

What am I doing wrong that its not waiting for the jquery plugin to finish loading before attempting to execute?

private native void makeHtml(Element element)
/*-{
  $wnd.$().ready(function(){
    try{
      $wnd.$(element).wmd({"preview": true});
      alert(1);
    }
    catch(e)
    {
      alert(e);
    }
  });
}-*/;
+1  A: 

I had some problems with jQuery UI in GWT because for example the array was not extended like jQuery (UI?) needed (note that the JSNI code is executed in a sandbox = iframe). Try putting the problematic code in a function in the main/host HTML page and call it from the Java/GWT code via JSNI and $wnd - if that helps, then you might be looking at the same problem I faced (in which case you'd probably have to "export" all your JSNI functions outside of the GWT code and wrap them in JSNI calls).

HTH, if not, we'll think of something else ;)

Igor Klimer
+1  A: 

In your widget, create an onLoad() method to call the jsni.

cometta