1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    79
    Vote Rating
    1
    jonathansimmons is on a distinguished road

      0  

    Default Multiple hidden toolbar buttons vs single dynamically changing button (best practice)

    Multiple hidden toolbar buttons vs single dynamically changing button (best practice)


    So I'm developing an app based around a navigation view. At various times in the app I'm showing and hiding buttons in the navigationBar. As of now I've created a separate button for each action needed and set it hidden by default, showing/hiding as necessary.

    This morning I though of an alternative: Say I had 10 buttons that display in the toolbar at different times throughout my app. I could reduce the numbers of buttons I actually instantiate by reusing buttons that have the same purpose, (a done button for a form for example).

    So say I have a 3 done buttons for 3 separate forms. I could essentially use the same button for each form by setting the action of that button to be relevant to the form.

    Anyone have any thoughts on what might be better for performance? more buttons super specific, less buttons with dynamically set actions....

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


    If you can consolidate number of components you use is very much suggested for performance as long as you don't have to do too much to reuse.

    I often use the action custom property on buttons and in the controller have listeners for button with certain actions. This would be very easy to change the action property and set the text.
    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.