What is the best way to add a function to a button? ( specfically scoped )
Dirty example:
form.Login= function(config){
if ( typeof config !== 'object' ) { config = {}; }
var tbarBottom = {
xtype: 'toolbar',
dock: 'bottom',
items: [{
xtype:'spacer'
},{
text: 'Reset',
handler:function(button,event){
console.log(this); // ehh... how do I this.reset() from here?
//( "this" is the buttons scope, not the forms scope )
}]
}
config.dockedItems= [tbarBottom];
form.Login.superclass.constructor.call(this,config);
Ext.extend( form.Login, Ext.form.FormPanel,{
reset: function() {
this.reset()// I want to call this function
}
});
I've seen examples in ExtJs 4 using
this.up('form').reset();
and I can also
this.ownerCt.ownerCt.reset()
But both those feel very awkward somehow. ( the .up much less so, though since I am playing with touch , i dont think "up" is an option)
Use this
{
text: 'Reset',
handler:function(button,event){
console.log(this); // ehh... how do I this.reset() from here?
//( "this" is the buttons scope, not the forms scope )
},
scope : this
}