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).
0 · ·
Comments
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
- Spam
- Abuse
0 · Off Topic Insightful ·Thanks, that's very appreciated. I appreciate the explanation.
- Spam
- Abuse
0 · Off Topic Insightful ·