2

The title pretty much says it all. I'm trying to use jQuery's ability (hoping GWTQuery has implemented it) to pass a callback function to the window.resize something like this(example from jquery site):
$(window).resize(function(){
alert("Stop it!");
});
but when I tryi to type $(window) in Eclipse I get an error that window can not be resolved. If anyone's interested in the bigger picture I'm basically trying to get an indciation from the window that is has finished the resizing operation and thus available for further resizing.

Thanks for any help Ittai P.S. please no lectures about browser development and resizing as I'm developing an in house app which just happens to use a browser.

Ittai
  • 5,625
  • 14
  • 60
  • 97

2 Answers2

5

This functionality has been added to GWTQuery as of 2010-05-03. See http://code.google.com/p/gwtquery/issues/detail?id=32

Imports required:

import static com.google.gwt.query.client.GQuery.$;
import static com.google.gwt.query.client.GQuery.window;

after this, you can access the window using

$(window);

However, no resize() function exists. To respond to a window resize, you can instead register a ResizeHandler to GWT's own window class, like this:

class OnWindowResize implements ResizeHandler {
    @Override
    public void onResize(ResizeEvent event) {
        int width = event.getWidth();
        int height = event.getHeight();


    }   
}

com.google.gwt.user.client.Window.addResizeHandler(new OnWindowResize());
OliverUv
  • 588
  • 5
  • 11
0

OK, To the best of my knowledge, testing and info searches GWTQuery does not support the jQuery syntax of retrieving the window. This might be related to the fact that GWT has already a Window class (although it is very partial) but I'm not sure. This is true for the time being (Dec` 09) and might change in the future.

Ittai
  • 5,625
  • 14
  • 60
  • 97