No GWTquery function is working

Deadly 提交于 2019-12-11 15:11:58

问题


I am trying to use GWTquery in my project. I have successfully added the jar file, added it to the class-path, imported all classes, but still nothing is working. Can anyone tell me what I am missing? Here is the code:

import static com.google.gwt.query.client.GQuery.*;
import com.google.gwt.query.client.plugins.Effects;
public class myfoo implements EntryPoint {
  public void onModuleLoad() {

        final TextBox tb = new TextBox();
        tb.setStyleName("foo"); 
        VerticalPanel panel = new VerticalPanel();
        panel.add(tb);
        $(".foo").setText("loo");
        $(".foo").click(new Function() {
            public boolean f(Event e) {
                tb.setText("foo");
                return true;  
            }
        });
        RootPanel.get().add(panel);
      }
     }

At pageload the text-box remains empty, not filled with loo. Aslo clicking on it has no effect.


回答1:


I belive $(".foo") cannot match your text box has it hasn't yet been added to the document. Try moving the RootPanel.get().add(panel) line before the $(".foo") ones.



来源:https://stackoverflow.com/questions/14400401/no-gwtquery-function-is-working

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