开发者

DOM ready in GWT

开发者 https://www.devze.com 2023-03-31 23:26 出处:网络
Is there somethin开发者_运维知识库g like jquerys ready() in GWT. I add an iframe and will check when the DOM is ready.document.ready() is similar to the onModuleLoad() method in your GWT EntryPoint. T

Is there somethin开发者_运维知识库g like jquerys ready() in GWT. I add an iframe and will check when the DOM is ready.


document.ready() is similar to the onModuleLoad() method in your GWT EntryPoint. They both execute, when the document is ready.


You can create a deferred command to execute when the browser event loop returns.

boolean ready=false;
public void onModuleLoad() {
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        @Override
        public void execute() {
            ready=true;
            Window.alert(ready+"");    
        }
    });
    for (int i=0;i<9999;i++){
        RootPanel.get().add(new Label(ready+""));
    }
}

This example places 9999 labels at DOM, only after then alerts true


Not really: it isn't a paradigm that really translates well to Java. You might want to just include jQuery or Zepto and use the ready function from one of those.

0

精彩评论

暂无评论...
验证码 换一张
取 消