PDA

View Full Version : Problem extending Observable...



Martin Chilvers
16 Feb 2010, 2:33 AM
Howdee folks,

I'm trying to 'subclass' Ext.util.Observable' and my first step was to try to run the example code from the API docs.

Sadly, the call to 'Employee.superclass.constructor.call(config)' fails on line 1285 of ext-all-debug.js with:-

TypeError: Object #<an Object> has no method 'on'

The code I lifted from the API docs is shown below:-

Any help greatly appreciated!

Martin



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!");
}
}
});

evant
16 Feb 2010, 2:48 AM
Employee.superclass.constructor.call(this, config);


I'll add a fix to the docs.

Martin Chilvers
16 Feb 2010, 3:04 AM
Thanks Evan!