PDA

View Full Version : Overloading a function always causes errors?



quaidbrown
11 Jan 2012, 8:53 AM
I have my own store:


Ext.define('AM.store.AppointmentStore',{
extend: 'Ext.data.Store',
model: 'AM.model.AppointmentModel',
autoLoad: true,
requires : ['AM.proxy.AppointmentAjaxRemoteProxy'],

proxy: {
type: 'myajax',
api: {
create : '/SchedulingService/Appointment/SetAppointment',
read : '/SchedulingService/Appointment/Appointments',
update : '/SchedulingService/Appointment/SetAppointment',
destroy : '/SchedulingService/Appointment/SetAppointment'
},
reader: {
type: 'json',
root: 'GetAppointmentsResult',
successProperty: 'success'
}
},
sync : function(){
console.log("Syncing appointment store");
this.superclass.sync();
}

//Ext.create('AM.proxy.AppointmentAjaxRemoteProxy')

});


I overload the sync function, print something to the console and immediately call the superclass.
This causes an error.

Ext.data.store:

getNewRecords: function() {
return this.data.filterBy(this.filterNew).items;
},


When I use the overload, this.data resolves to undefined resulting in the obvious 'cannot call method filterBy of undefined'. When I don't use the overload resolves correctly. Why does this happen?

quaidbrown
11 Jan 2012, 10:32 AM
Fixed with:

this.superclass.sync.call(this);