Why should changing a tab have all this code, it should be as simple as toggling the visible content pane i.e classView Vs typeView.
All data that needs to be rendered for both views should be rendered at once on page.