Javascript component becomes invisible on tab change

I have two javascript components inside different tabs, both have the same problem: change tabs and then back to the JS tab, and the component disappears.
Can someone suggest any root cause and remedy?



This info from couple of years back is still valid:!/thread/11043585/11043584

“Have you written beforeClientResponse() method in your class which extends AbstractJavaScriptComponent? TabSheet is not caching the hidden tabs, so when user changes tabs, the content is completelyh redrawn. Hence beforeClientResponse() needs to be implemented in javascript component, which takes care of calling appropriate function to redraw the content.”

Interesting, now I need to decide what parts of the JS code should be invoked from beforeClientResponse… for example fully create a new instance of the Java class, or use the same instance reinitializing everything as originally…
I’ll try several variations.