extjs - Sencha touch 2: Set button handler parameter to lunch javascript function -
i using sencha touch o'really example. conference have sessions , speakers associated. imagine have session list when tapped view change session details.
i have view this:
ext.define('myapp.view.session.detail', { extend: 'ext.container', xtype: 'session', config: { layout: 'vbox', title: '', items: [ { flex: 1, layout: 'fit', scrollable: 'vertical', xtype: 'sessioninfo' }, { flex: 2, xtype: 'speakers', store: 'sessionspeakers', items: [ { xtype: 'listitemheader', cls: 'dark', html: 'speakers' } ] }, { flex: 1, xtype: 'button', text: "decline button" , handler: function () { /*here want put data session object. example */ alert({title}); alert({start_date}); alert({location}); } } ] }
}); so, want replace {title} {start_date} {location} corresponding values of current session.
by way in controller have this:
onsessiontap: function(list, idx, el, record) { var speakerstore = ext.getstore('sessionspeakers'), speakerids = record.get('speakerids'); speakerstore.clearfilter(); speakerstore.filterby(function(speaker) { return ext.array.contains(speakerids, speaker.get('id')); }); if (!this.session) { this.session = ext.widget('session'); } this.session.settitle(record.get('title')); this.getsessioncontainer().push(this.session); this.getsessioninfo().setrecord(record); },
thanks!!
i resolve it. had create button on runtime. :
in session view:
ext.define('myapp.view.session.detail', { extend: 'ext.container', xtype: 'session', config: { layout: 'vbox', title: '', items: [ { flex: 1, layout: 'fit', scrollable: 'vertical', xtype: 'sessioninfo' }, { flex: 2, xtype: 'speakers', store: 'sessionspeakers', items: [ { xtype: 'listitemheader', cls: 'dark', html: 'speakers' } ] } ] }
});
in session controller:
onsessiontap: function(list, idx, el, record) { var speakerstore = ext.getstore('sessionspeakers'), speakerids = record.get('speakerids'); speakerstore.clearfilter(); speakerstore.filterby(function(speaker) { return ext.array.contains(speakerids, speaker.get('id')); }); if (!this.session) { this.session = ext.widget('session'); } else{ //to avoid multiple buttons this.session.removeat(2); } this.session.settitle(record.get('title')); this.session.add( ext.button.create({ flex: 1, xtype: 'button', text:'my button' , handler: function () { alert(record.get('title')); alert(record.get('start_date')); } }) ); this.getsessioncontainer().push(this.session); this.getsessioninfo().setrecord(record); },
Comments
Post a Comment