manolo / gwt-polymer-elements

Polymer Web Components for GWT. A collection of Material Design widgets for desktop and mobile.
Apache License 2.0
155 stars 49 forks source link

PaperToggleButtonElement addEventListener #108

Closed Fritz75 closed 7 years ago

Fritz75 commented 8 years ago

I'm using UiBinder and want to add a PaperToggleButtonElement and then add an event:

XML: /p:PaperToggleButton

Java class: @UiField public PaperToggleButtonElement myToggle;

myToggle.addEventListener("iron-change", new EventListener() { @Override public void handleEvent(Event event) { //doSomething } }); in developer console I get this.myToggle_1_g$.addEventListener is not a function

Please, can you help me in any way?

manolo commented 7 years ago

If you use widgets in your ui.xml you should use widgets in the .java

You code works if you modify:

  <p:PaperToggleButton ui:field="myToggle" />
@UiField
public PaperToggleButton myToggle;
....

  myToggle.getPolymerElement().addEventListener("iron-change", e -> {
     console.log("Change");
  });