4 Oct 2007 4:26 AM #1
[2.0a1] Tabs are not removed from TabPanel when events suspended
We have an application that uses different sets of tabs, depending on a selected tree node.
When the user activates a different tree node, all tabs are cleared and new ones are created. They may be the same as before, but can also be less or more tabs.
This is done by using the TabPanel.remove() function.
We would like to save the last active tab before a node switch and restore this tab afterwards, if it is contained in the new tab-set.
The idea is the following:
- on every "tabchange" we read the given tab-id and store it in a variable
- remove all tabs when user changes tree node
- build new ones and use setActiveTab() with the stored id
But now we are running into a problem:
When a tab is removed using TabPanel.remove(), it automatically activates the next visible tab which triggers the "tabchange"-event. This is bad because it also changes the stored active tab information.
When calling suspendEvents() before removal to prevent the problem, no tab is being removed (visually). Same result with purgeEvents() (worked in Ext 1.x) which seems like a bug to me.
Is this a bug that will be fixed in future or is there a better way to remove tabs without calling tabchange events ?
Thanks in advance.
4 Oct 2007 5:07 AM #2
If you suspend the events, you are telling it to stop communicating. This means it has no way to know that it needs to remove the tab. I don't recommend using suspendEvents unless you know exactly what is being suspended and you plan on firing the appropriate events manually when you resume.
This is like a help request, rather than a bug so I am going to move it to the help forum.
My suggestion would be to remove the tabchange listener before you start removing the tabs. If for some reason you don't have a reference to the function, you can do:
Sencha Co-Founder, Ext JS Founder
Original author of Ext JS 1, 2 & 3.
4 Oct 2007 5:19 AM #3
Thanks for your fast reply, your solution solved the problem !