PDA

View Full Version : Available elements to use in listeners



dekely
9 Nov 2013, 7:42 AM
Hi All,What are the available elements to be used in listerens?I'm trying to add a click listener on a panel's header but it doesn't work.

[CODE]
dblclick : {
fn: function() {
if(tabConfig.maximizable){
Ext.getCmp(tabConfig.id).maximizeTab();
}
},
element: 'header'
}
[/COEE]

dawesi
10 Nov 2013, 4:09 AM
Ok, so the docs: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.panel.Header-event-dblclick


either :
so get the reference to the header:


panel.getHeader().on('dblclick', this.yourFn);

or
in a controller


Ext.define('MyApp.controller.MyController', {
extend: 'Ext.app.Controller',

onHeaderDblClick: function(header) {
... your code ...
},

init: function(application) {
this.control({
"panel #bob header": {
dblclick: this.onHeaderDblClick
}
});
}

});

or
(bad practice)
use listeners on the view



header: {
listeners : {
dblclick : function() {
...do something...
}
}
}

dekely
10 Nov 2013, 4:23 AM
OK, now it works



render: function(){
this.getHeader().on({
dblclick: {
fn: function() {
if(tabConfig.maximizable){
Ext.getCmp(tabConfig.id).maximizeTab();
}
}
}
});
}


Thanks!