PDA

View Full Version : TabPanel events



samlinux
3 Jan 2012, 7:24 AM
Hi,
which event is fired, if one tap ist clicked, in ST1 there was a click event?

In ST2 i can`t find an event, which I can use in my controller to catch the tap event ???





Ext.define('App.controller.Main',{
extend: 'Ext.app.Controller',
// registriere die views

views: [
'Desk1'
],
refs: [
{
ref: 'myTab',
selector: '#myTab'
}
],

init: function(){

if(_debug)console.log("Controller gestartet");

this.control({

'#myTab' : { show : 'handleItemChange'}
});

},
handleItemChange: function(){
console.log("test");
}
});

mitchellsimoens
3 Jan 2012, 7:46 AM
tap events are on the elements, not components.

samlinux
3 Jan 2012, 8:43 AM
http://www.sencha.com/forum/showthread.php?161806-“el”-listener-not-working-in-Sencha-Touch-2&p=691670&viewfull=1

samlinux
3 Jan 2012, 10:16 AM
Is the post below also the reason why my control function do`t catch the tap event ??




this.control({
'#myTab': {
tap: this.onKlick
}
});





Ext.define('App.view.Desk1', {
extend: 'Ext.tab.Panel',
alias: 'widget.viewDesk1',
id: 'myTab',
config: {
fullscreen: true,
activeItem: 0,
tabBarPosition: 'bottom',
cardSwitchAnimation: {
type: 'slide',
cover: true
},
defaults: {
scrollable: 'vertical',
styleHtmlContent: true
},
items: [
{title: 'B1', iconCls: 'info', id: 'tab1',html:'test 1'},
{title: 'B2', iconCls: 'user', id: 'tab2', html: 'test2'} ]

},
initialize: function(){
this.callParent();
this.element.on({
tap: function(){
var activeTab = Ext.getCmp("myTab").getActiveItem();
if(_debug)console.dir(activeTab.title);
console.log("klick in View");

}
});
}

});

mitchellsimoens
3 Jan 2012, 10:38 AM
this.control cannot listen to elements, just components. What I usually do is add the listener in my class definition in the initialize method and then fire that event on the component and then this.control can then listen for it.


initialize : function() {
var me = this;

me.callParent(arguments);

me.element.on({
scope : this,
tap : 'bubbleTapEvent'
});
},

bubbleTapEvent: function(e, t) {
this.fireEvent('tap', this, e, t);
}

samlinux
3 Jan 2012, 11:09 AM
thanks man, it works now