0

Jqueryライブラリをプロジェクトに追加しようとしています。その後、ツールチップを使用して「プラグイン」を実行するために、tipsy.jsも追加します。

問題は、gwt.xmlファイルにすでにjsを追加したのに、jQueryに「$」を呼び出せないことです。

私のgwt.xmlファイルは:

<module ... 
  <!-- jquery and plugins -->
  <script src="/javascripts/jquery.min.js"></script>
  <script src="/javascripts/tipsy.js"></script>

jsで呼び出すメソッドは次のとおりです。

public static native void allClassName(String className) /*-{
  $wnd.jQuery(className).tipsy({trigger: 'focus', gravity: 'w'});
}-*/;

しかし、私はいつもこのエラーが発生しました:

at java.lang.Thread.run(Thread.java:680)原因:com.google.gwt.core.client.JavaScriptException:(TypeError):オブジェクト[オブジェクトウィンドウ]には、com.googleにメソッド'jQuery'がありません。 gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)atcom.google.gwt.dev.shell.ModuleSpace。 invokeNative(ModuleSpace.java:561)at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:289)at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107) netagenda.ui.gwt.client.gin.ClientGinjectorImpl.com $ gwtplatform $ mvp $ client $ HandlerContainerImpl_automaticBind_methodInjection_ _ _(ClientGinjectorImpl.java)at netagenda.ui.gwt.client.gin.ClientGinjectorImpl.memberInject_Key $ type $ netagenda $ ui $ gwt $ client $ pages $ backend $ customers $ presenter $ CustomerPagePresenter $ _annotation $$ none $$(ClientGinjectorImpl.java :1395)netagenda.ui.gwt.client.gin.ClientGinjectorImpl.create_Key $ type $ netagenda $ ui $ gwt $ client $ pages $ backend $ Customers $ presenter $ CustomerPagePresenter $ _annotation $$ none $$(ClientGinjectorImpl.java:1408 )at netagenda.ui.gwt.client.gin.ClientGinjectorImpl.get_Key $ type $ netagenda $ ui $ gwt $ client $ pages $ backend $ Customers $ presenter $ CustomerPagePresenter $ _annotation $$ none $$(ClientGinjectorImpl.java:1421)at netagenda.ui.gwt.client.gin.ClientGinjectorImpl $ 13 $ 1.onSuccess(ClientGinjectorImpl.java:2768)のnetagenda.ui.gwt.client.gin.ClientGinjectorImpl.access $ 12(ClientGinjectorImpl.java:1419) 。芯。client.GWT.runAsync(GWT.java:255)

4

2 に答える 2

2

次のように、ファイルを home.html ファイルに追加することを解決しました。

    <!-- jquery and plugins -->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">  </script>
    <script src="http://onehackoranother.com/projects/jquery/tipsy/javascripts/jquery.tipsy.js"></script>

この後、プラグインを呼び出すための gwt を使用した私のメソッドは次のとおりです。

    public static native void allClassName(String className) /*-{
      $wnd.jQuery(className).tipsy({trigger: 'focus', gravity: 'w'});
    }-*/;
于 2012-09-20T16:10:10.407 に答える