Results 1 to 2 of 2

Thread: New list displaying data from previously destroyed list

  1. #1
    Touch Premium Member
    Join Date
    Aug 2011
    Location
    Arkansas
    Posts
    18
    Vote Rating
    0
      0  

    Default New list displaying data from previously destroyed list

    In my application I have a tab panel with a few lists each bound to JSON stores. When the user clicks a logout button the navigation view (which contains the tab panel) is destroyed and another user can login. I can confirm that the lists are destroyed on logout because Ext.ComponenyQuery.query('list') returns empty.

    Code:
         
           logoutButton: {           
                  tap: function () {
                        Ext.Msg.confirm('Logout', 'Are you sure you want to logout?', function (button) {
                            if (button == "yes") {
                                this.getMainViewport().remove(this.getNavView(), true);
                            }
                        }, this);
                    }
                },
    When another user logs in and the tab panel is displayed, the lists have the previous data. The stores for each list are created in the config of the list view:
    store: Ext.create("MyApp.store.AJsonStore")

    Since the lists are destroyed and I create the store in the config of the list, I assume everything is "cleared out" and I start fresh each time. But somehow the list is retaining the data.

    I call getStore().load() on the list when it is first shown, so this isn't a huge problem, but the old data is there for a second while the new data loads. What is going on?

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Answers
    3931
    Vote Rating
    1272
      0  

    Default

    You shouldn't use Ext.create in the config like that, that store will remain alive and used for any instance. You should do this:

    Code:
    config : {
        ...
        store : { type : 'mystoretype' }
    }
    And on your store:

    Code:
    Ext.define('....', {
        extend : 'Ext.data.Store',
        alias  : 'store.mystoretype',
    
        ....
    });
    Notice in red the linking between the list's store config and the store's type. Now, the only thing that *should* be able to trip this up is if you define a storeId on the store, don't do that.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •