Calling Javascript function of .js file from java GWT code

后端 未结 2 1875
忘掉有多难
忘掉有多难 2021-01-01 21:19

I have one button in Java GWT code. And I have one javascript file in scripts folder. I want to access functions of that js file on Button click.

So how can I call t

2条回答
  •  甜味超标
    2021-01-01 22:00

    since your code should not depend on the gwt linker (and how it loads code) you need to prefix the call with the right window object. Reapp does not take that into account. So it actually needs to be:

    public static native void onMyButtonClick() /*-{
        $wnd.myJSfunction();
    }-*/;
    

提交回复
热议问题