You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GwtQueryWidgetModule.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package gwtquery.samples.client;
  2. import static com.google.gwt.query.client.GQuery.$;
  3. import com.google.gwt.core.client.EntryPoint;
  4. import com.google.gwt.event.dom.client.ClickEvent;
  5. import com.google.gwt.event.dom.client.ClickHandler;
  6. import com.google.gwt.query.client.Function;
  7. import com.google.gwt.query.client.GQuery;
  8. import com.google.gwt.query.client.plugins.Widgets;
  9. import com.google.gwt.user.client.Element;
  10. import com.google.gwt.user.client.Event;
  11. import com.google.gwt.user.client.Window;
  12. import com.google.gwt.user.client.ui.Button;
  13. public class GwtQueryWidgetModule implements EntryPoint {
  14. public void onModuleLoad() {
  15. $("<button>Enhance</button>").appendTo(".outer").one(Event.ONCLICK, null, new Function() {
  16. public boolean f(Event e) {
  17. $(".btn:nth-child(odd)").each(new Function(){
  18. public void f(Element el) {
  19. // Replace odd labels by a button
  20. GQuery g = $("<button/>");
  21. $(el).hide().after(g);
  22. // Use the Widgets plugin to convert the button element to a button.
  23. Button b = g.as(Widgets.Widgets).widget();
  24. b.setText("Foo");
  25. b.addClickHandler(new ClickHandler() {
  26. public void onClick(ClickEvent clickEvent) {
  27. Window.alert("You Clicked the Button");
  28. }
  29. });
  30. }
  31. });
  32. return true;
  33. }
  34. });
  35. }
  36. }