PDA

View Full Version : Incorrect info in docs for Observable?



dbassett74
15 Jul 2009, 9:22 AM
I am trying to utilize the example code provided in the latest docs for Ext.util.Observable, but it keeps giving me the error "me.on is not a function". Here is the code that I am using, which is verbatim out of the docs:



Employee = Ext.extend(Ext.util.Observable, {
constructor: function(config){
this.name = config.name;
this.addEvents({
"fired" : true,
"quit" : true
});

// Copy configured listeners into *this* object so that the base class's
// constructor will add them.
this.listeners = config.listeners;

// Call our superclass constructor to complete construction process.
Employee.superclass.constructor.call(config)
}
});
var newEmployee = new Employee({
name: employeeName,
listeners: {
quit: function() {
// By default, "this" will be the object that fired the event.
alert(this.name + " has quit!");
}
}
});

Where is the problem? If I remove the "listeners" from the var newEmployee code, it runs, but that I can't respond to events. Any help would be appreciated.

aconran
15 Jul 2009, 8:54 PM
Employee.superclass.constructor.call(config)


You are missing a this as the first argument of call.