1. #1
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Connecticut
    Posts
    541
    Answers
    8
    Vote Rating
    36
    blomasky has a spectacular aura about blomasky has a spectacular aura about

      0  

    Default Answered: Can I have more than one action point to the same function?

    Answered: Can I have more than one action point to the same function?


    Many times I have multiple buttons (i.e. add 10%, add 20%) that I want to call the same function (action) and let the function determine what to do by the component passed. It seems that an action in SA3 has to be unique to one control query. Am I missing something?

    The way I am handling this now, is to add the 2nd (and any additional) events in the "init" function.

    Is there a better way?

    Thanks
    Bruce

  2. Quote Originally Posted by blomasky View Post
    The problem is, that an action requires a "UNIQUE" name for each function. I didn't know is there is a trick to re-use one, besides just having a listener in the INIT function...
    I understand your issue... I was just giving a work-around for the limitation.

  3. #2
    Sencha - Architect Dev Team
    Join Date
    Jan 2009
    Location
    Frederick, Maryland
    Posts
    810
    Answers
    57
    Vote Rating
    31
    jminnick has a spectacular aura about jminnick has a spectacular aura about

      0  

    Default


    Quote Originally Posted by blomasky View Post
    Many times I have multiple buttons (i.e. add 10%, add 20%) that I want to call the same function (action) and let the function determine what to do by the component passed. It seems that an action in SA3 has to be unique to one control query. Am I missing something?

    The way I am handling this now, is to add the 2nd (and any additional) events in the "init" function.

    Is there a better way?

    Thanks
    Bruce

    Maybe create a global function that all the unique functions can call?

    Code:
    function handleAllButtons(btn) {
    }
    
    btnTap1: function(button, e, eOpts) {
        handleAllButtons(btn);
    }
    
    btnTap2: function(button, e, eOpts) {
        handleAllButtons(btn);
    }
    
    btnTap3: function(button, e, eOpts) {
        handleAllButtons(btn);
    }
    Jason Minnick
    Sencha Architect Development Team

  4. #3
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Connecticut
    Posts
    541
    Answers
    8
    Vote Rating
    36
    blomasky has a spectacular aura about blomasky has a spectacular aura about

      0  

    Default


    The problem is, that an action requires a "UNIQUE" name for each function. I didn't know is there is a trick to re-use one, besides just having a listener in the INIT function...

  5. #4
    Sencha - Architect Dev Team
    Join Date
    Jan 2009
    Location
    Frederick, Maryland
    Posts
    810
    Answers
    57
    Vote Rating
    31
    jminnick has a spectacular aura about jminnick has a spectacular aura about

      0  

    Default


    Quote Originally Posted by blomasky View Post
    The problem is, that an action requires a "UNIQUE" name for each function. I didn't know is there is a trick to re-use one, besides just having a listener in the INIT function...
    I understand your issue... I was just giving a work-around for the limitation.
    Jason Minnick
    Sencha Architect Development Team

  6. #5
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,264
    Answers
    8
    Vote Rating
    80
    ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough ssamayoa is a jewel in the rough

      0  

    Default


    Quote Originally Posted by blomasky View Post
    Many times I have multiple buttons (i.e. add 10%, add 20%) that I want to call the same function (action) and let the function determine what to do by the component passed. It seems that an action in SA3 has to be unique to one control query. Am I missing something?

    The way I am handling this now, is to add the 2nd (and any additional) events in the "init" function.

    Is there a better way?
    With custom attribute and use it in the selector?
    Code:
    {
        xtype: "button",
        text: "Up 20%",
        _action: "up20"
    }...
    Then:
    Code:
    this.control({
        "mypanel button [_action=up20]":
            click: this.someMethod
        }
        ...
    )
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi