-
19 Jul 2012 2:49 AM #1
Unable to un store event
Unable to un store event
Ext version tested:
- Ext 4.1.1rc2
- FF14
- Listen for store load event and then un the created function
- Create a store in a controller and using the 'on' method - add a listener for the load event to fire
- 'un' the load events function
- The 'on' load event calls the function once!
- the function for on is called everytime the event load is fired
Inside my controller
When using the refresh button on the pagingtoolbar, the above function is called again. I know that I can add the filters parameter to the store.load({scope, callback, filters}) method... however, then the pagingtoolbar is unaware of the filters at a later stage (i.e. when using the refresh button).Code:var store = Ext.create('App.store.MyStore') store.filter([{ property:'id', value: myID }]); //calls ->Load()<- ! store.on("load", function(a,b,c ...){ var panel = Ext.create("App.view.myGridPanel"); this.showInQuickView(panel); this.application.fireEvent("loadDone"); store.un('load', arguments.callee); //doesn't 'un' the event function - even if store is a handedover from the function parameter (in this case = a) }, this);
Possible fix:- add a var i = 0, then stick an if(i==0) inside the above function so the code is only executed once by adding i++ (increment) after the if statement
-
19 Jul 2012 3:05 AM #2
This isn't a bug. When you remove the event, you also need to pass the scope along.
Also, if you want a single fire event, you can use the single param:
Code:store.on('load', function(){ }, this, {single: true});Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
19 Jul 2012 3:10 AM #3
Superb... checked the documentation to see if it is there.. and it is
Must have glanced over it. Thanks for the great and very quick reply
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote