When trying to inject jQuery through ScriptInjector, this is the error thrown when $wnd.$ is called through JSNI:
Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): Object [object global] has no method '$' at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136) at com.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)
Here is the code to inject jQuery:
ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js")
.setWindow(ScriptInjector.TOP_WINDOW).setCallback(new Callback<Void, Exception>() {
@Override
public void onSuccess(Void arg0) {
GWT.log("Success to load jQuery library");
ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js").setWindow(ScriptInjector.TOP_WINDOW).inject();
}
@Override
public void onFailure(Exception arg0) {
GWT.log("Failed to load jQuery library");
}
}).inject();
What could be the problem?