Situation with "recycling" views on multiview

Hi,

In my app, i switch back and forth between cells, via menu events. In this particular case, I’m rebuilding the views (reusing id’s) completely and re-adding them to the multiview, every single time (this kinda defeats the purpose of multiview, but bear with me please, I’m learning as I go). This is causing me a problem where, after going back to a view a second time, I get an error like Uncaught TypeError: Cannot read property ‘style’ of null . I’ve trying destroying the old view before switching, but that doesn’t seem to avoid the error.

The only way I’m avoiding it is actually rebuilding the multiview every single time, but that seems overkill (and obviously kills the animation effects). I’m missing something for sure. What cares should I take when doing something like this?

thanks

Normally the only thing which you need to do - call component destructor. It will remove view and will remove all references. You need to call destructor only for topmost view, all inner views will be removed automatically.

In case of multiview it is a bit more complicated, as you need both old and new views ready on animation start. To make things more simple you can place the layouts in the cells of multiview and instead of rebuilding the cells itself - redefine the content of layouts

http://webix.com/snippet/cc80e89c

webix.ui call here is shortcut for full layout reloading, it will delete the old content of layout and fill it with new configuration. With such code the animation of multiview will not be affected.

P.S. Content of non-active cells in multiview does not rendered at all. So you can define a lot of screens without visible performance drawback.

Thanks maksim, I’m going to try this.