1. #1
    Sencha Premium Member
    Join Date
    Oct 2010
    Posts
    33
    Vote Rating
    0
    Answers
    2
    adeelmahmood is on a distinguished road

      0  

    Default Answered: firing events on controller from view

    Answered: firing events on controller from view


    I am not sure how I can fire an event on the controller from my view. I want the event to be triggered from the view .. something like

    Code:
    listeners: {
    itemtap: function(dv, i, t, r, evt){ console.log('itemtap called'); //get the selected element var el = Ext.get(evt.target); //fire the selected event this.fireEvent('tapListingItem', r, el); } }
    on the controller side I want to capture this event but I dont want to create a hard reference to this list. I simply want the event to be fired on the controller without it knowing about who fired it Because the same controller is supposed to handle these events from multiple lists.

    Thanks
    Adeel

  2. This is up to your ComponentQuery in the control config in the controllers. If it is generic enough then it won't be bound to knowing the application structure.

    Code:
    control : {
        'dataview' : {
            tapListingItem : 'onTapListingItem'
        }
    }
    That is generic to listen to any tapListingItem event on any dataview (or subclass like List).

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,650
    Vote Rating
    899
    Answers
    3575
    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


    This is up to your ComponentQuery in the control config in the controllers. If it is generic enough then it won't be bound to knowing the application structure.

    Code:
    control : {
        'dataview' : {
            tapListingItem : 'onTapListingItem'
        }
    }
    That is generic to listen to any tapListingItem event on any dataview (or subclass like List).
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

Thread Participants: 1