Jsni gwt jquery

I have a jQuery file to create a flip card effect, and I changed it to JSNI using the built-in function, but an error. I do not know what happened. Can anybody help me? This is my own function:

public native void flip() /*-{ $(document).ready(function () { $('#nav-list-example div div.back').hide().css('left', 0); function mySideChange(front) { if (front) { $(this).parent().find('div.front').show(); $(this).parent().find('div.back').hide(); } else { $(this).parent().find('div.front').hide(); $(this).parent().find('div.back').show(); } } $('#nav-list-example div').hover( function () { $(this).find('div').stop().rotate3Di('flip', 250, {direction: 'clockwise', sideChange: mySideChange}); }, function () { $(this).find('div').stop().rotate3Di('unflip', 500, {sideChange: mySideChange}); } ); }); }-*/; 
+4
source share
2 answers

JSNI 101 : $wnd.$($doc).ready(function($) {…

Using $ as an argument to a callback function should allow $ to be used inside the function instead of $wnd.$ .

+7
source

I always use this:

 $wnd.jQuery($doc).ready(function(){}); 

Inside the function, you can make an "alias" for jQuery, for example:

 function(){ var _ = $wnd.jQuery; // go on.... } 

Hope this helps :)


By the way: this is how we did it in GWT-Bootstrap.

+4
source

Source: https://habr.com/ru/post/1415171/


All Articles