DOM ready in GWT

若如初见. 提交于 2019-11-29 11:42:20

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!