At the moment, we just call Application.CreateForm(class, 'contentform', ...) to attach a content form to the form container element 'contentform' despite the fact whether the content form has been created before. This requires to somehow backup the content form's state and restore it the next time the content form is created. On the other hand, there seems to be no way to detach an active content form from the container element and (re)attach an already created content form. Any suggestions?
If I understand correct, when you create a form in a container element, the form replaces the content in the container element and the "previous" content is not saved automatically by the framework. If you would want to "restore" the previous content, you'd need to recreate the form previously hosted in the container.
Yes. In another post there was stated that the HTML of a created content form is lost after being assigned to the container element. If the content form's HTML would be preserved, I could imagine just assigning this preserved HTML to the innerHTML of the container element without recreating the content form.
At the moment we test an alternative, where each content form has its own container element and dynamically switching the CSS display property of the container elements to block or none to only display the content form that should be visible.
I would recommend your 2nd approach, as just replacing InnerHTML will break all event handler bindings to controls that might be in this HTML.
Thank you for that clarification/recommendation.