问题
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