Thiem Nguyen
Thiem Nguyen

Reputation: 6365

Recommended way to add/remove items from a Ext.Container in Sencha Touch 2?

I am optimizing my application. Originally, it's a Ext.TabPanel but I decided to use only a Ext.TabBar docked at the bottom and change the views above, so it requires a lot of add/remove actions from my main Ext.Container.

So my question is: in what way I should do to add/remove items from my Ext.Container effectively? I mean: fast, not cause memory-leaks, and also, not cause error like this: the view with a button in it, firstly added, all handlers (which are define through refs and control in a controller) work well but the second time (i.e it's removed and added again later), all handlers die.

Thanks in advance!

Upvotes: 4

Views: 41728

Answers (1)

stan229
stan229

Reputation: 2607

You have to ensure that you destroy the panel is destroyed otherwise it would be sitting in the dom.

Generally to remove a component from a container you use the Container remove() function which takes in the first parameter as the item to be removed and the second one is a boolean which instructs for it to be destroyed or not. You should ensure you set it to true to make sure you keep your DOM as lean as possible. Unless you're going to be reusing that component in the near future and do not want to render it again, then you do not need to destroy it.

http://docs.sencha.com/touch/2-0/#!/api/Ext.Container-method-remove

Upvotes: 6

Related Questions