8 Aug 2014 10:59 AM #1
controller with # in selector will register only once?
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:
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:
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.
11 Aug 2014 2:14 PM #2
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.
11 Aug 2014 2:19 PM #3
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.
11 Aug 2014 10:24 PM #4
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.
12 Aug 2014 10:29 PM #5
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.