jeffbvox
6 Feb 2011, 12:07 PM
In the Blog post at http://www.sencha.com/blog/event-delegation-in-sencha-touch/, Tommy M says that it's possible to have multiple delegates in the same list row in the comments, but I can't seem to make it work. Has anyone had any luck with it.
I have two images with different classes applied in the same list row, and I want to fire two different event handlers. Tried a variety of methods, but the example that's in @gcallaghan's post didn't seem to work. It seems only the last one specified will work (I'm guessing it overwrites the first).
Here is what I tried (among other things):
itemList = Ext.extend(Ext.List, {
itemTpl: new Ext.XTemplate(
'<img src="public/resources/images/buttons/PlayButton33X33.png" height="33" width="33" align="absmiddle" class="playButton"/>',
'{Name}',
'<img src="public/resources/images/buttons/AddToCart50x50_grey.gif" height="25" width="25" class="addToCartButton"/>',
),
listeners: {
el: {
tap: function() {
alert('Play Pressed!')
},
delegate: '.playButton'
},
el: {
tap: function() {
alert('Add Track To Cart pressed!')
},
delegate: '.addToCartButton'
}
},
initComponent: function() {
itemList t.superclass.initComponent.apply(this, arguments);
//this.enableBubble('selectionchange');
}
});
I have two images with different classes applied in the same list row, and I want to fire two different event handlers. Tried a variety of methods, but the example that's in @gcallaghan's post didn't seem to work. It seems only the last one specified will work (I'm guessing it overwrites the first).
Here is what I tried (among other things):
itemList = Ext.extend(Ext.List, {
itemTpl: new Ext.XTemplate(
'<img src="public/resources/images/buttons/PlayButton33X33.png" height="33" width="33" align="absmiddle" class="playButton"/>',
'{Name}',
'<img src="public/resources/images/buttons/AddToCart50x50_grey.gif" height="25" width="25" class="addToCartButton"/>',
),
listeners: {
el: {
tap: function() {
alert('Play Pressed!')
},
delegate: '.playButton'
},
el: {
tap: function() {
alert('Add Track To Cart pressed!')
},
delegate: '.addToCartButton'
}
},
initComponent: function() {
itemList t.superclass.initComponent.apply(this, arguments);
//this.enableBubble('selectionchange');
}
});