Results 1 to 3 of 3

Thread: Store event on success load

  1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    19

    Default Answered: Store event on success load

    I have an MVC application. In one part I'm showing list of clients with possibility to add new one, view/edit details of existing.
    I want to load the client list when accessing specific action, especially when there is possibility of entering actions not one by one (so user can access client detail view without visiting clients list first). On each controller actions I put
    Code:
    App.stores.ClientStore.load();
    App.stores.ClientStore.on('load', function(store, records) {
      ...
    }, this);
    because I want to show the panel after the store is loaded, and every data is available.
    This would work perfectly, but listeners created by "on" method are global. This cause multiple calling of each line of code written in listeners for load event after accessing any action.
    Is there a way of executing some code only for this one specific store load? The best could be
    App.stores.ClientStore.load({success: function() {...}}) but the specification only provided callback function and I'm pretty sure it's called without waiting for succesfully loading... Can you help me?

  2. I would set the listener before executing the load. Further more you can do this:

    Code:
    store.on('load', function() {}, store, { single : true });
    single means that the listener will fire once and remove itself.

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,451
    Answers
    3997

    Default

    I would set the listener before executing the load. Further more you can do this:

    Code:
    store.on('load', function() {}, store, { single : true });
    single means that the listener will fire once and remove itself.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    19

    Default

    Thank you! Works perfectly with {single: true}. I also moved initiating the listener before loading the store as you suggested

Posting Permissions

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