开发者

jquery ready not waiting for plugins to finish loading

开发者 https://www.devze.com 2022-12-17 12:58 出处:网络
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.

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 jquer开发者_如何学编程y 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);
    }
  });
}-*/;


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 ;)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消