Search code examples
javascriptgwtsmartgwtnative-code

how to call javascript function from SmartGWT function


hi all i am trying to call a native Js function called test i wrote in the HTML file in the smartGWT project but it sayes test is not a function

the native java script code in the smartGWT class :

public static native void  callTest()/*-{
        window.test();

}-*/;

the java script function in the HTMLfile :

 <script  type="text/javascript">   
    function test(){
        window.alert("test");
    }
    </script>

and i also added :

<script src="org.example.yourcode.Spiffy.nocache.js"></script>

but as i mantaind it sayes test is not a function so dos any one have any idea or any one can provide any help please ?
thanx

and when i add $window.test() instead window.test() i get the following message ?

enter image description here
and when i use $wnd.test(); i had the following error :

Error when using $wnd.test()


Solution

  • just try adding '$' in front of window.test(). i.e. $window.test() and see.