fixed sidebar with dynamic content

I dynamically generate a sidebar (with html links to other pages). When clicking on the sidebar, I want to populate the content to the right. I already created a sidebar view and when a link is clicked another view is loaded, which also reloads the sidebar (because I again include the sidebar in that view). I want to however keep that sidebar fixed, and to just load the content. Reason for this is I do not want to lose where the sidebar has been scrolled to. The sidebar houses a complex tree I designed.

I thought of creating a layout with the sidebar, but the sidebar itself is not a fixed tree. It can change based on data.

Some ideas or general pointers would be appreciated.