I'm building my own class with extjs 3 (license issue)
Ext.ux.MyClass = Ext.extend(Ext.Container, {
initComponent: function() {
this.button = new Ext.Button({
scope:this,
text:'my button',
handler: function() {
alert(0);
this.fireEvent('myevent');
}
});
this.addEvents('myevent');
}
});
//in the code:
var obj = new Ext.ux.MyClass(...);
obj.on('myevent', function () {alert(1);});
The event was not fired the code does not give error I can see the Alert(0) but not Alert(1);
I tried the listener but also not working and the this.fireEvent returns true.
Thanks for your help
What version of ExtJS 3 are you using? 3.0, 3.1 or 3.4?
If it's 3.4 then it seems to work for me. I've added a little bit of extra code just to get the button to render but it seems ok to me.
The final code I'm using is:
Ext.onReady(function(){
Ext.ux.MyClass = Ext.extend(Ext.Container, {
initComponent: function() {
this.button = new Ext.Button(
{
renderTo: document.body,
scope:this,
text:'my button',
handler: function() {
alert(0);
this.fireEvent('myevent');
}
});
this.addEvents('myevent');
}
});
var obj = new Ext.ux.MyClass();
obj.on('myevent', function () {alert(1);});
});
Check out the jsfiddle here: http://jsfiddle.net/J9YcL/
I'm running in Chrome if that makes any difference.