Return to Snippet

Revision: 40349
at January 31, 2011 12:07 by djbabylon


Initial Code
Ext.setup({
    onReady: function(){
    
        Ext.regModel('Contact', {
            fields: ['firstName', 'lastName']
        });
        
        var main = new Ext.Panel({
            fullscreen: true,
            layout: 'card',
            items: [{
                xtype: 'list',
                tpl: '<tpl for="."><div class="contact"><strong>{firstName}</strong> {lastName}</div></tpl>',
                itemSelector: 'div.contact',
                store: new Ext.data.Store({
                    model: 'Contact',
                    data: [{
                        firstName: 'Tommy',
                        lastName: 'Maintz'
                    }, {
                        firstName: 'Ed',
                        lastName: 'Spencer'
                    }, {
                        firstName: 'Jamie',
                        lastName: 'Avins'
                    }]
                }),
                listeners: {
                    itemtap: function(list, index){
                        var rec = list.store.getAt(index),
                            id = rec.get('firstName') + '-card',
                            c = main.getComponent(id);
                        
                        if(!c){
                            c = main.add({
                                itemId: id,
                                html: rec.get('lastName'),
                                dockedItems: [{
                                    xtype: 'toolbar',
                                    dock: 'top',
                                    items: [{
                                        text: 'Back',
                                        ui: 'back',
                                        handler: function(){
                                            main.setCard(0);
                                        }
                                    }]
                                }]
                            });
                            main.add(c);
                        }
                        main.setCard(c, 'slide');
                    }
                }
            }]
        });
    }
});

Initial URL

                                

Initial Description
Lists need to be wrapped in Panels

Initial Title
Sencha Touch: List that opens into panels

Initial Tags

                                

Initial Language
JavaScript