2 Jun 2012, 7:32pm
gwt:

3 comments




  • Anzeige
  • How to Use JQuery in GWT

    After adding the JQuery script to your project HTML file’s header section

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

    You will be able to use JQuery in native (JSNI) meth­ods by prepend­ing $wnd., e.g.:

    private native void someMethod() /*-{
    	$wnd.$(function() {
    		$wnd.$('#somediv').doSomething();
    	});
    }-*/;

    With­out $wnd. you will end up with fol­low­ing error: com.google.gwt.core.client.JavaScriptException: (ReferenceError): $ is not defined

    Thanks for shar­ing! Saved my life ;)

    mine too. Thanx!

    […] For instance you can code in Java if you want to or have exist­ing source code and then use jQuery for other stuff. There are avail­able wrap­pers, but GWT can call JavaScript (and vice versa) see http://svenbuschbeck.net/wordpress/2012/06/how-to-use-jquery-in-gwt/ […]

    *name

    *e-mail

    web site

    leave a comment