-
16 Nov 2011 9:15 AM #1
Answered: Tap listeners not working with list view
Answered: Tap listeners not working with list view
Hi,
I have a panel which consists of a list and a top toolbar. I've assigned a listener to the itemtap event but nothing happens when I tap on any of the items. It's supposed to display an alert message and print a message to the console. Aside from the listeners, everything else works perfectly and there's no error shown in the console.
The following is the panel code.
Any help? Thank you.Code:Pouch.views.ItemIndexView = Ext.extend(Ext.Panel, { layout: 'fit', initComponent: function() { this.store = new Ext.data.Store({ autoLoad: true, model: 'Pouch.models.Item', }); this.dockedItems = [{ xtype: 'toolbar', dock: 'top', title: 'Pouch', }]; this.list = new Ext.List({ itemTpl: '<div class="item">{name} ${price}</div>', store: this.store, listeners: { scope: this, itemtap: this.onItemtapAction, }, }); this.items = [this.list]; Pouch.views.ItemIndexView.superclass.initComponent.apply(this, arguments); }, onItemtapAction: function(list, index, item, e) { Ext.Msg.alert("HAHAHAHAHA!"); console.log("HAHAHAHAHAHA!!!!!!"); }, }); Ext.reg('ItemIndex', Pouch.views.ItemIndexView);
-
Best Answer Posted by AndreaCammarata
Hi.
Try to remove the commas reported in red color.
Hope this helps.Code:this.list = new Ext.List({ itemTpl: '<div class="item">{name} ${price}</div>', store: this.store, listeners: { scope: this, itemtap: this.onItemtapAction, }, });
-
16 Nov 2011 10:10 AM #2
Hi.
Try to remove the commas reported in red color.
Hope this helps.Code:this.list = new Ext.List({ itemTpl: '<div class="item">{name} ${price}</div>', store: this.store, listeners: { scope: this, itemtap: this.onItemtapAction, }, });Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
17 Nov 2011 6:20 AM #3
Cool, it finally works now! Thank you so much. Being more of a backend developer, I cannot understand why the commas can cause the problem in JavaScript. I read from somewhere that it's a good practice to append comma to the last element. Mind explaining it to me? Thank you.
-
17 Nov 2011 10:46 AM #4
You are welcome.
That's no true.
In fact, if you try to validate the following json using JSONLint, you will notice that this will show you an error.
Hope this helps.Code:[ { "firstName": "Tommy", "lastName": "Maintz" }, { "firstName": "Rob", "lastName": "Dougan" }, ]Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata


Reply With Quote