Skip to content

Add model.item to Event #78

Open
Open
@ghost

Description

Declarative event handlers inside a "dom-repeat" add the model object to the event. If we make the model available on the elemental.Event then it is possible to get the data from the item when an event is fired.

@JsType(isNative=true, namespace=GLOBAL)
public interface Event {
     ....

    @JsProperty TemplateInstance getModel();

    @JsType(isNative=true, namespace=GLOBAL)
    public interface TemplateInstance {
        @JsProperty <T> T getItem();
    }
}

Example:
So if the "dom-repeat" template contains an event handler (a.e. <paper-button on-tap="onTapFct">) then we get the binded data on each event.

Polymer.function(bindTemplate, "onTapFct", event -> {
    Foo foo = ((Event) event).getModel().getItem();
});

final List<Foo> data = createData();
repeatTemplate.setItems(Polymer.asJsArray(data));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions