1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    2
    Vote Rating
    0
    slsu90 is on a distinguished road

      0  

    Default 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.
    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);
    Any help? Thank you.

  2. Hi.
    Try to remove the commas reported in red color.

    Code:
    this.list = new Ext.List({
    		            itemTpl: '<div class="item">{name} ${price}</div>',
    		            store: this.store,
    		            listeners: {
    		                scope: this,
    		                itemtap: this.onItemtapAction,
    		            },
    		        });
    Hope this helps.

  3. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Answers
    148
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Hi.
    Try to remove the commas reported in red color.

    Code:
    this.list = new Ext.List({
    		            itemTpl: '<div class="item">{name} ${price}</div>',
    		            store: this.store,
    		            listeners: {
    		                scope: this,
    		                itemtap: this.onItemtapAction,
    		            },
    		        });
    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    2
    Vote Rating
    0
    slsu90 is on a distinguished road

      0  

    Default


    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.

  5. #4
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Answers
    148
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    You are welcome.

    Quote Originally Posted by slsu90 View Post
    I read from somewhere that it's a good practice to append comma to the last element.
    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.

    Code:
    [
        {
            "firstName": "Tommy",
            "lastName": "Maintz"
        },
        {
            "firstName": "Rob",
            "lastName": "Dougan"
        },
    ]
    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi