1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    392
    Vote Rating
    6
    gkatz is on a distinguished road

      0  

    Default controller with # in selector will register only once?

    controller with # in selector will register only once?


    Hi guys;
    in my scenario I have a single controller for my app, a side menu and a main area that is dynamic, meaning each click on the side menu destroys the current view in the dynamic area and creates a new view that was chosen.

    one of these views is a settings view (xtype: 'settingsView') with some input fields (toggle, spinners etc) grouped by a fieldset component (with id= myFieldset). my app controller receives changeEvent on these fields in the following way:
    controll:{
    '#myFieldset'...
    .....

    this works but only once!. after a user chooses a different view and the settings view is destroyed and then the user return back to the settings view for the second time, the events are not captured by my controller.
    changing the control config to:
    controll:{
    'settingsView fieldset'
    yields good results.
    so, my questions is, is it a known issue that when using #id in the controll function, it will only register once?
    thanks and sorry for the long story.

  2. #2
    Sencha - Support Team
    Join Date
    Mar 2012
    Location
    Lawrence, KS
    Posts
    260
    Vote Rating
    33
    greg.barry has a spectacular aura about greg.barry has a spectacular aura about

      0  

    Default


    My guess is that not everything is being destroyed and creating a new view is causing an ID collision.

    Generally speaking, you're not going to want to use IDs for this very reason. It really prevents your application from being dynamic.

    I would suggest a few things:

    1) Make sure ALL children of the container you're destroying are also being destroyed.
    2) Use itemId instead of ID, as it provides a more dynamic nature to your application.

    Thanks!
    Greg

  3. #3
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,937
    Vote Rating
    130
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    Yes this is a known issue. itemId are unique to containers and once the container is destroyed they become invalid. Though I thought this only applied to itemId used in the ref config and not the control config.
    Get more personalized support via a support subscription.

    Want to learn Sencha Touch 2? Check out
    Sencha training
    Sencha Touch in Action

    Need more help with your app? Hire Sencha Services services@sencha.com

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

  4. #4
    Sencha User
    Join Date
    Nov 2010
    Posts
    392
    Vote Rating
    6
    gkatz is on a distinguished road

      0  

    Default


    thanks guys;
    actually itemId did the trick and it works ok. my selector looks like 'path to component[itemId=<my item id>]' now. so the problem is with ids only.
    I do destroy everything so it must be something internal to sencha.
    BTW, after setting the itemId I dont see it rendered in the DOM tree as a part of the component DOM, so how exactly does it work? a short explanation would be great.
    thanks!

  5. #5
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,937
    Vote Rating
    130
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    Ooops. I misread your first post. I thought you were using itemId. itemId are used internally by the framework. itemId's are an index to the container's internal MixedCollection of children.
    Get more personalized support via a support subscription.

    Want to learn Sencha Touch 2? Check out
    Sencha training
    Sencha Touch in Action

    Need more help with your app? Hire Sencha Services services@sencha.com

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

Thread Participants: 2

Tags for this Thread