1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    8
    Vote Rating
    0
    lrochfort is on a distinguished road

      0  

    Default Controller listen to custom events in Architect 2

    Controller listen to custom events in Architect 2


    Hi,

    I want to decouple my Controller from my View, and as such do not want my Controller to listen to events raised by particular View components, but rather to application specific events that are raised by the View.

    For instance, have the List select event fire an editRow event in the View and then have the Controller listen for this event and act accordingly.

    When adding a Controller Action in Architect 2 I'm not able to manually enter and EventBinding name, only select one of the standard ones for the component type.

    Is what I want to do sensible and is there an Architect 2 construct for it?

    Any advice would be appreciated.

    Regards,
    Laurence.

  2. #2
    Sencha User kubens's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    136
    Vote Rating
    0
    kubens is on a distinguished road

      0  

    Default


    You can add a listener in the init method of your controller:

    PHP Code:
    init: function(application) {
      
    this.addManagedListener(application'i18nChange'me.onI18nChangeme);
    },
    onI18nChange: function() {
      
    alert('onI18nChange');


  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    8
    Vote Rating
    0
    lrochfort is on a distinguished road

      0  

    Default


    Thank you kubens.

    FYI, addManagedListener is deprecated and has been replaced by addListener. http://docs.sencha.com/touch/2-0/#!/...anagedListener

  4. #4
    Sencha User kubens's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    136
    Vote Rating
    0
    kubens is on a distinguished road

      0  

  5. #5
    Sencha Premium Member
    Join Date
    Mar 2012
    Posts
    38
    Vote Rating
    2
    rklowe01 is on a distinguished road

      0  

    Default


    but how would you fire an event from say, a button press, that would be handled by the controller. I added the following line to my button handler:

    this.fireEvent('CustomEvent', button);

    and my controller is set up to listed for onCustomEvent.

    But when I press the button , the controller function onCustomEvent is not called.

    If this can't work in Architect, is there another way to just call a controller function directly from within a button press handler? (or a way to call a global function)?

    Thanks in advance...

  6. #6
    Sencha Premium Member
    Join Date
    Nov 2007
    Posts
    79
    Vote Rating
    4
    oldroy is on a distinguished road

      0  

    Default


    I'd like to know the same thing. In complex apps this would be something that architect would need to allow. Seems that controlling all components and their event directly by ref and control in the controller would make some really big, fat, ugly controllers. If you could have the choice to push some of that out to the views (which are really kind of "view-controllers" not purely views anyway) it would be nice.

    I'd like to know if there is a performance difference in your scenario. As in, does controlling the button by ref and control in the controller directly perform better/faster than firing a custom event and trying to manage that?

  7. #7
    Touch Premium Member pmarko's Avatar
    Join Date
    Dec 2007
    Location
    Ireland
    Posts
    56
    Vote Rating
    1
    pmarko is on a distinguished road

      0  

    Default


    +1

  8. #8
    Sencha User
    Join Date
    Jan 2009
    Location
    US
    Posts
    46
    Vote Rating
    0
    zlog is on a distinguished road

      0  

    Default


    is this working now?

  9. #9
    Touch Premium Member BostonMerlin's Avatar
    Join Date
    Aug 2010
    Location
    Boston
    Posts
    497
    Vote Rating
    41
    BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about BostonMerlin has a spectacular aura about

      1  

    Default


    Example:

    in a button tap event add:
    Code:
    this.fireEvent('cmdDoSomethingForMe');
    drag a controller action to a controller then set:
    controlQuery: container
    targetType: Ext.Button
    fn: onCmdDoSomethingForMe
    params: button
    name: cmdLoadEntities
    controlQuery and targtType would change as needed. Hope that helps a little. JB

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar