PDA

View Full Version : fireEvent is not cathced inside controller for object created dynamically



American horizon
26 May 2016, 3:08 AM
hi
i've this store defined:



Ext.define( "CS.store.Titolari",
{
extend:"Ext.data.Store",
model:"CS.model.Titolare",
storeId: "Titolari",
id: "Titolari",
proxy: {
type:"ajax",
headers : { 'Content-type' : 'application/json', 'accept': 'application/json' },
listeners : {
exception : function(proxy, response, operation) {
console.log("exception event");
Ext.getStore("Titolari").fireEvent("error",response); },
},
});


When the load data goes in exception, it fires an event that i manage inside the controller. It works when i use the store in the main panel of my application, but if i instantiate another store of the same type, i see that "error" event is not fired anymore, such if the controller loose the "listener",

this is the piece of code that i've inside controller:


var store = Ext.create('CS.store.Titolari', {buffered:false});
store.add( btn.up("form").getValues());
var those=this;
store.sync({
failure: function(proxy, response, operation){ those.getTitolariStore().fireEvent("error", response); //don't work!
}
});
}

Why?