PDA

View Full Version : Why does calling a var function not fire?



profunctional
30 Jun 2010, 4:54 PM
The following code below will not fire my event:


{
xtype: 'button',
ui: 'mask',
iconCls: 'add',
stretch: false,
handler: addJob
}
var addJob = function() {
alert('addJob');
}


But this fires just fine


{
xtype: 'button',
ui: 'mask',
iconCls: 'add',
stretch: false,
handler: function() {
alert('addJob');
}
}

Riaz
11 Oct 2010, 7:07 PM
Code may be like -



var btnbutton = new Ext.Button({
iconMask:true,
iconCls: 'add',
handler: function(){
addJob.apply(btnbutton);
}
});

var addJob = function(botton) {
alert('addJob');
}