DOM ready in GWT

后端 未结 3 2036
情书的邮戳
情书的邮戳 2020-12-19 18:27

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

3条回答
  •  醉梦人生
    2020-12-19 18:57

    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

提交回复
热议问题