chaplinjs/chaplin

Is it possible to hide and show View without to dispose them?

danielesalvatore opened this issue · 4 comments

Good morning everyone,

First of all I want to thank you for the project. I recently discover it and it seems to address all the issue I faced during the implementation of a recent project i took part of. I am excited to try it.

Going through the documentation I understood the the power of memory management of the library lies on a the process of disposing of the views (following its controller disposition).

In my case, a mobile app project, it is not convenient to remove completely a view because its content is generated after heavy computation and at the moment I instantiate the views on their fist show, and hide/show after it.
I noticed the hideOldView() and showNewView() methods but I am not sure they are what i need.

I would like to know if ChaplinJS gives the possibility to achieve it. If yes, could you provide an example?

Thank you very much in advice for your reply and your time.

Why can't you use CSS for this?

Good morning @chrisabrams, thank you for your reply.

Of course it is possible. Actually I use the jQuery hide() and show() functions at the moment during my route changing and basically it is a shortcut to alter CSS.

My question was more about how to configure the library to do not let dispose a controller during a route change (and consequentially do not remove its views from the DOM) and hide its views instead.
My concerns are more about if this logic is foreseen in ChaplinJS and how technically achieve it, stopping the disposing flow to apply the show/hide one.

Thank you again.

@danielefenix See http://docs.chaplinjs.org/chaplin.composer.html Your use-case is already covered by Controller#reuse

Thanks for pointing it out!

Thanks again for the support and congrats for the project.