DOM ready in GWT

2020-02-12 16:40发布

Is there something like jquerys ready() in GWT. I add an iframe and will check when the DOM is ready.

标签: gwt domready
3条回答
Summer. ? 凉城
2楼-- · 2020-02-12 17:19

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

查看更多
爷、活的狠高调
3楼-- · 2020-02-12 17:24

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.

查看更多
干净又极端
4楼-- · 2020-02-12 17:32

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

查看更多
登录 后发表回答