DOM已准备好在GWT中 [英] DOM ready in GWT

查看:80
本文介绍了DOM已准备好在GWT中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GWT中是否有像jquerys ready()的东西。我添加一个iframe,并检查DOM何时准备就绪。

/google-web-toolkit.ggo.core =nofollow>延迟命令,以便在浏览器事件循环返回时执行。

  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 +));




$ b

这个例子在DOM上放置了9999个标签,提醒真实

Is there something like jquerys ready() in GWT. I add an iframe and will check when the DOM 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

这篇关于DOM已准备好在GWT中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆