PDA

View Full Version : store.on('load... fire count is window reopen count



slsb02
10 Dec 2013, 10:15 PM
Hello,

i have a window with, Grid


store: store_DataCall,
data: [store_DataCall.load()],
columns: [{


in window is:


beforeshow: function() {
store_DataCall.on('load', function(store, records) {
console.log("test");
});
}


1. first open fire: test
2. second open fire: test, test
3. third open fire: test, test, test

what is wrong?

Thank you!

Kevin Jackson
16 Dec 2013, 3:08 PM
Could you send a screen cap of the console.log so I can see how you are getting there and what you are seeing?

girish.arjunagi
16 Dec 2013, 4:53 PM
Are you recreating the window object every time you open?
If yes, Then you need to unregister the load event before close/destroy of window. Use an un method to un register the load event.

slsb02
16 Dec 2013, 8:35 PM
Hello,

@girish.arjunagi what is the best way, to unregister the load event.
I have not found a solution!

Thank you for your reply!

girish.arjunagi
16 Dec 2013, 9:02 PM
Instead of using the inline event handler use the named function, which will be used as reference while un registering the events. Try with the below code. Hope this might help you.



beforeshow: function() {
store_DataCall.on('load', this.onStoreLoad, this);
},
onStoreLoad : function(store, records) {
console.log("test");
}
//on destroy or close of window
onDestroy : function(){
this.callParent(arguments);
store_DataCall.un('load', this.onStoreLoad, this);
}

slsb02
16 Dec 2013, 9:47 PM
beforeshow: function() {
dataStore.on('load', this.onStoreLoad, this);
},
onStoreLoad : function(store, records) {
console.log("test");
}

show in console:

TypeError: listener.fireFn is undefined


and no changes when using:
beforedestroy: function() {

dataStore.un('load', this.onStoreLoad, this);