1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    48
    Vote Rating
    0
    Answers
    3
    celwell is on a distinguished road

      0  

    Default Answered: Fire Event from Store and receive in List view

    How do I get that alert to fire in the List view upon store loading?

    Coffeescript:

    List:
    Code:
    Ext.define 'WSI.view.EventsList',
      extend: 'Ext.List'
      xtype: 'eventslist'
      config:
        listeners:
          showLoading: ->
            alert 'showLoading in EventsList heard'
            @fireEvent 'showLoading', 0
    Store:
    Code:
    Ext.define 'WSI.store.Events',
      extend: 'Ext.data.Store'
      xtype: 'eventsstore'
      config:
        model: 'WSI.model.Event'
        autoLoad: false
        pageSize: 15
        listeners:
          beforeload: ->
            @fireEvent 'showLoading', 0
          load: ->
            @fireEvent 'hideLoading', 0

  2. You would have to fire the event on the store and then add a listener within the list to listen to it:

    Code:
    Ext.define('MyList', {
        extend : 'Ext.dataview.List',
        xtype  : 'my-list',
    
        //...
    
        updateStore: function(newStore, oldStore) {
            if (oldStore) {
                oldStore.un('storeLoading', 'onStoreLoading', this);
            }
    
            if (newStore) {
                newStore.on('storeLoading', 'onStoreLoading', this);
            }
        },
    
        onStoreLoading : function() {
            //....
        }
    });
    Man, IMO Coffeescript is ugly

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    38,546
    Vote Rating
    1120
    Answers
    3700
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default

    You would have to fire the event on the store and then add a listener within the list to listen to it:

    Code:
    Ext.define('MyList', {
        extend : 'Ext.dataview.List',
        xtype  : 'my-list',
    
        //...
    
        updateStore: function(newStore, oldStore) {
            if (oldStore) {
                oldStore.un('storeLoading', 'onStoreLoading', this);
            }
    
            if (newStore) {
                newStore.on('storeLoading', 'onStoreLoading', this);
            }
        },
    
        onStoreLoading : function() {
            //....
        }
    });
    Man, IMO Coffeescript is ugly
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    48
    Vote Rating
    0
    Answers
    3
    celwell is on a distinguished road

      0  

    Default

    Thanks!

    Funny, I thought coffeescript looked so nice and it saves so many commas when using Sencha Touch. It can be cluttered though because if you space it out too much then it can get confusing.

Thread Participants: 1

Tags for this Thread