Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    62
    Vote Rating
    0
    stevanicus is on a distinguished road

      0  

    Default Unable to un store event

    Unable to un store event


    Ext version tested:
    • Ext 4.1.1rc2
    Browser versions tested against:
    • FF14
    Description:
    • Listen for store load event and then un the created function
    Steps to reproduce the problem:
    • 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 result that was expected:
    • The 'on' load event calls the function once!
    The result that occurs instead:
    • the function for on is called everytime the event load is fired
    Test Case:

    Inside my controller
    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);
    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).

    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

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    15,237
    Vote Rating
    105
    evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold

      1  

    Default


    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!

  3. #3
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    62
    Vote Rating
    0
    stevanicus is on a distinguished road

      0  

    Default


    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

Tags for this Thread