Buttons as part of a repeater

edited April 2012 in Enyo 2
I'm a new enyo developer, but I'm completely stuck. When I have an onyx.Button as the row in my repeater, I cannot get ontap to trigger.

This is the relevant snippet

{name: "scroll", kind: "Scroller",fit: true, style: "height: 100%;", components: [
{name: "rep", kind: "Repeater", onSetupRow:"setupEntries", components:[
{kind: "onyx.Button", ontap: "showEntries"}
]},
]},
and this is the definition for showEntries (just a place holder right now).

showEntries: function(inSender, inEvent) {
enyo.log("showEntries");
this.log(inEvent.originator.owner);
}
Am I doing something wrong? I have no idea what's breaking, or why. My Web Inspector window isn't showing any errors (running this in Safari).

Comments

  • edited April 2012
    Unfortunately, Repeater is tricky with respect to events.

    Repeater creates a wrapper object for each row that is the owner for the set of controls in that row. This is done to maintain the unique-name-in-owner requirement, but it means that event handlers declared inside the repeater won't work properly.

    The work around is to create a kind that will contain your repeating items, handle DOM events internally to that kind, and then bubble custom events up to the application.

    Here is an example:

    http://jsfiddle.net/qUSdZ/

    We are working on better options for repeating content (aka lists) that will be available soon.

    Depending on your needs, you may be better off simply managing your repeating objects yourself, like this:

    http://jsfiddle.net/8XAjj/

    Scott
  • Scott,

    Thanks, that's very appreciated. I appreciate the explanation.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter