2

is there something like the jquerys .ready() function for GWT?

 $(document).ready(function () {
  alert("The DOM is now loaded and can be manipulated.");
});

I need a possibility to check when the site has been loaded completely and is now ready to use.

I know there is the way to do it like this:

FlowPanel mainPanel = new FlowPanel();
mainPanel.addAttachHandler(new AttachEvent.Handler() {

  @Override
  public void onAttachOrDetach(AttachEvent event) {
    // do something
  }
});

But im not sure, if this is really the same like jquerys .ready().

Does anyone know of something like .ready() in GWT?

sockeqwe
  • 15,574
  • 24
  • 88
  • 144
  • There's not a function that I know of that is an equivalent of jQuery's `ready()`. That being said, I think it's safe to assume that you can perform DOM manipulation in an `AttachEvent` handler. Out of curiosity, what are you looking to achieve? – Chris Cashwell Feb 08 '12 at 12:39
  • possible duplicate of [DOM ready in GWT](http://stackoverflow.com/questions/7244938/dom-ready-in-gwt) – Chris Cashwell Feb 08 '12 at 12:50

1 Answers1

1

As in the linked question, onModuleLoad() is effectively the same as the ready event. By default, onModuleLoad doesnt run until after all of the resources in the page have loaded.

Any given widget's AttachEvent refers only to that widget, that it has been attached to the dom and may be manipulated. When onModuleLoad, existing content in the dom (the initial html page) is ready to be manipulated.

Community
  • 1
  • 1
Colin Alworth
  • 17,801
  • 2
  • 26
  • 39
  • Oh thank you. Another question, is there a way or a Event, that tells me when everything on my side is loaded completely, including static resources like css and images files? – sockeqwe Feb 09 '12 at 12:49
  • If the content was on the main html page, my understanding is that it has loaded when onModuleLoad runs. If you mean in general, if there is an event fired from the page whenever all currently outstanding requests have finished, then no. As you create new requests, depending on how they are made, you can often add handlers for those specific load events though - see Image and its addLoadHandler as one example. – Colin Alworth Feb 10 '12 at 19:02