1. #1
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    557
    Vote Rating
    25
    estesbubba will become famous soon enough estesbubba will become famous soon enough

      0  

    Default [WISHLIST] Controllers control{} that can handle application events

    [WISHLIST] Controllers control{} that can handle application events


    In our 2 current Touch 2 applications we have 2 kinds of events:
    - events that views fire
    - events that controllers fire

    It appears that control{} can only be used to listen to view events. We've tried and haven't been able to listen to controller events, so our code looks like

    Code:
        config: {
            control: {
                'main #nextButton': {
                    tap: 'onNextButtonTap'
                },
    
    
                'main #backButton': {
                    tap: 'onBackButtonTap'
                }
    
    
            },
    
    
            refs: {
                main: 'main',
                entryForm: 'entryform',
                scanBarCode: 'scanbarcode'
            }
        },
    
    
        init: function() {
            var me = this;
    
    
            me.getApplication().on({
                startAccountLookup: me.startAccountLookup,
                barCodeReaderEvent: me.barCodeReaderEvent,
                scope: me
            });
    
    
        },
    What would be nice is for control to be able to handle both events (maybe it can and we're just missing it).It seems several people have been posting on the 2.0 Discussion forum confused how to handle non-view events.

    How about something like an 'application' selector so all events can go under control{}?

    Code:
        config: {
            control: {
                // view events
                'main #nextButton': {
                    tap: 'onNextButtonTap'
                },
    
    
                'main #backButton': {
                    tap: 'onBackButtonTap'
                },
                
                // controller events
                'application': {
                    startAccountLookup: 'startAccountLookup',
                    barCodeReaderEvent: 'barCodeReaderEvent'
    
    
            },
    
    
            refs: {
                main: 'main',
                entryForm: 'entryform',
                scanBarCode: 'scanbarcode'
            }
        }

  2. #2
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    I've moved this to Discussion as it's not a bug... I'm not sure this is such a great path to start down as it dilutes the purity of control meaning CQ selection-based events and opens up the expectation that we'll therefore support model events, store events and anything else that may throw events, all from the control block.

    I'd rather we have a convention around attaching events listeners to the Application just like any other observable:

    Code:
    init: function() {
        this.getApplication().on({
            someEvent: this.takeSomeAction
        });
    }
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  3. #3
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    557
    Vote Rating
    25
    estesbubba will become famous soon enough estesbubba will become famous soon enough

      0  

    Default


    Ed thanks for explaining. We are doing application events exactly how you posted. I think some people are confused how to handle non-view events and hopefully this clears it up.

  4. #4
    Sencha - Community Support Team edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default


    I'll add this to the docs
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

Thread Participants: 1