1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    53
    Vote Rating
    0
    Answers
    2
    paul_todd is on a distinguished road

      0  

    Default Answered: Controller and id resolutionadd

    Answered: Controller and id resolutionadd


    Hi,

    I have a controller with a ref of myListview #myAddButton.

    ref {
    add: 'myListview #myAddButton'
    }

    I also have a control with
    control: {
    add: {tap: 'onAddTapped'}
    }

    If I have another view with a button with an id of #myAddButton but no controller then the other view seems to get called rather than this controller. If I rename the myAddButton id to something else then it works fine.

    The question is do the id's for elements have to be unique across all views in order for the controller to route properly?

  2. id has to be unique, itemsId has to be unique to that container. It is best to stay away from them for this reason. I use a custom property 'action' to specify what a button is for.

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


    id has to be unique, itemsId has to be unique to that container. It is best to stay away from them for this reason. I use a custom property 'action' to specify what a button is for.
    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.

  4. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    53
    Vote Rating
    0
    Answers
    2
    paul_todd is on a distinguished road

      0  

    Post


    mmm,

    I had one panel where I had a list and a button in it and another panel where I had a different list id but the same button id. Both panels had different ids and xtypes. These two panels were in a card layout in another panel..

    It ran ok and the buttons were being controlled by a controller.

    Should I have got an error if there were duplicate id's?
    ie the ref I had, specifically said that I wanted to use the id within the xtype specified

    Ext.define('MyApp.controller.MyController', {
    extend: 'Ext.app.Controller',
    config: {
    refs: {
    add: 'myxtypepanel #mybutton'
    },
    control: {
    add: {
    tap: 'onMyButton'
    },
    }
    }
    }

Thread Participants: 1

Tags for this Thread