1. #1
    Touch Premium Member
    Join Date
    Aug 2011
    Posts
    34
    Vote Rating
    0
    Pandorian is on a distinguished road

      0  

    Default MVC and Component Listeners

    MVC and Component Listeners


    What I would like to do is take some action in my controller when the label part of a textfield is tapped.

    I have looked at the sticky post above and created a component listener like this:

    Code:
    itemId :'testit',
    xtype: 'selectfield',
    name: 'KS',
    label: 'Planning',
    store: 'ScoreKey',
    displayField: 'scoreKey',
    valueField: 'scoreKeyId',
       
    listeners: {
      tap: {
        fn: function() {
           this.fireEvent('editoutcomefull');
           //            alert('fire');
           },
        element: 'label'
      }
    }
    The alert will be displayed if the comment are removed. The problem I have is how do I fire an event that will be picked up by my controller?

    I looked at this.getApplication().fireEvent() but this cause an error, and I cannot get my controller to re-act to this.fireEvent.

    I have also tried adding a component listener to the controller directly, but couldn't get it to work.

    Anybody any ideas on the best way to achieve this?

  2. #2
    Sencha User
    Join Date
    Dec 2011
    Posts
    26
    Vote Rating
    0
    rhomb is on a distinguished road

      0  

    Default


    You could just use refs / controls to manage those events from the Controller
    http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller

    r
    ho

  3. #3
    Touch Premium Member
    Join Date
    Aug 2011
    Posts
    34
    Vote Rating
    0
    Pandorian is on a distinguished road

      0  

    Default


    Quote Originally Posted by rhomb View Post
    You could just use refs / controls to manage those events from the Controller
    http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller

    r
    ho

    Code:
    config: {
       refs: {
           KSTap:            'VisitOutcomes #testit'
       },
            
        control: {
            KStap: {
                tap: {
                        fn: function() {
                            alert('fire');
                        },
                        element: 'label'
                    },
             },
         }         
    },
    Yes, I have tried that, but the event doesn't seem to fire - not sure if the syntax is OK.

Thread Participants: 1