PDA

View Full Version : fireFn undefined



ID91
4 Jul 2012, 6:16 AM
I try to load a store, but for some reason I get this error in Google Chrome(latest version):


Uncaught TypeError: Cannot call method 'apply' of undefined ext-all-debug.js:8586
fire ext-all-debug.js:8586
Ext.define.continueFireEvent ext-all-debug.js:24623
Ext.define.fireEvent ext-all-debug.js:24601
Ext.define.onProxyLoad ext-all-debug.js:50186
Ext.define.processResponse ext-all-debug.js:39168
(anonymous function) ext-all-debug.js:39381
Ext.apply.callback ext-all-debug.js:6422
Ext.define.handleResponse ext-all-debug.js:18769
(anonymous function) ext-all-debug.js:1815
(anonymous function)

and this one in Internet Explorer 8:

Message: 'fireFn' is null or not an object

while FireFox(latest version) seems to ignore it.
I have inserted some new lines in ext-all-debug.js, so the line numbers may be off by 5-10 lines.
This is the store:


Ext.define("FI.store.units.InstallBaseStore", {
extend:'Ext.data.Store',
requires: "FI.model.units.InstallBaseModel",

model: "FI.model.units.InstallBaseModel",
storeId: 'installBaseStore',
pageSize:10,
proxy: {
type: 'jsonp',
url: urls.QSUrl+"/search",
limitParam: 'undefined',
startParam: 'offSet',
pageParam: 'undefined',
extraParams: {
searchString: '*:*',
index: "fleet",
role: "Admin"
},

reader: {
root: 'results.results',
totalProperty: 'numFound',
model: 'FI.model.units.InstallBaseModel'
}
},

listeners:{
beforeload: {
fn:function(){
console.log("BEFORE LOAD");
this.getProxy().setReader({
root: 'results.results',
totalProperty: 'numFound',
model: 'FI.model.units.InstallBaseModel'
});
console.log(this.getProxy().getReader());
}
}
}
});

Any ideas?

skirtle
4 Jul 2012, 1:05 PM
Which ExtJS version?

Obvious question, do you still get the error is you remove the listeners block in your example?

ID91
5 Jul 2012, 1:27 AM
The ExtJS version is 4.1.

I have solved the problem thanks to a comment from here:

http://stackoverflow.com/questions/11330323/extjs-undefined-function

It seems that I should have set the proxy in the model, not in the store. Fixing this, made the application work fine. The problem is, that I don't understand why this thing(supported by the documentation) proved to be an issue. From what I have read, it is possible to set the proxy within a store.

Can you please explain to me what I was doing wrong? I am trying to learn something from this, not just to fix the app.

Thank you!

skirtle
5 Jul 2012, 3:51 PM
While it may have solved your problem the advice on that Stack Overflow entry looks a little wayward to me.

Specifying a proxy on a store is perfectly valid. The proxy on the model is typically used to load a single instance of the model by its id whereas the proxy on the store will load multiple records based on some other criteria. Different stores can use the same model but have totally different proxies.

For example, if you had a User model then you might have two stores, one of normal users and one of admin users. The server requests to load these would be different so the stores would need different proxies. The proxy on the User model itself might be responsible for loading an individual User record by username.

While it's true that stores will use the model's proxy as a fall-back it doesn't mean it's the 'right' way to do it. It depends on your circumstances.

Having the line numbers off makes it pretty difficult to figure out what's going on. It's not entirely clear which event is firing in the error case, there are a couple of candidates.

That beforeload listener looks pretty suspicious to me. I'm also wondering whether it could be a reference sharing problem with something on your class's prototype. Though how that would give you a missing fireFn isn't entirely clear.

Do you have multiple instances of this store?

How are you initiating the load?

On a side note, you have strange values for limitParam and pageParam. I suspect that you want this:


limitParam: false,
startParam: 'offSet',
pageParam: false,