how to call a javascript function from an included javascript file using GWT?
I have a function Load() in a js file which I added to the GWT module.
I am trying to call it using
private static native void load() /*-{
$doc.Load();
}-开发者_开发技巧*/;
but it gives me error like
Error(s) occurred! (TypeError): $doc.Load is not a function fileName: http://localhost:8888/myapp/888C05FB242806B071A932498F6B5AD9.cache.html lineNumber: 1224
I even tried with $wnd.Load()
What the proper way of calling it?
Igor is correct. Consider the following snippet from the host HTML file:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="resources/css/gxt-all.css" />
<script language="JavaScript">
function dostuff() {
alert("Stuff is being done.");
}
</script>
<!-- -->
<!-- Consider inlining CSS to reduce the number of requested files -->
<!-- -->
<link type="text/css" rel="stylesheet" href="GxtSandbox.css">
And the following snippet from GWT code:
public void onModuleLoad() {
doGwtStuff();
}
public native void doGwtStuff() /*-{
$wnd.dostuff();
}-*/;
This alert is shown.
精彩评论