Keeping epanded Treemenu open

Keeping epanded Treemenu open

Hi,  I think this question has been asked before but I can't work out from other answers how to make mine work from it.  I know next to nothing about Jquery but have the below script on an ASP.NET MVC 5 _Layout page

  1. <script>
  2.         $(document).ready(function () {
  3.             $(".treeview li>ul").css('display', 'none'); // Hide all 2-level ul
  4.             $(".collapsible").click(function (e) {
  5.                 e.preventDefault();
  6.                 $(this).toggleClass("collapse expand");
  7.                 $(this).closest('li').children('ul').slideToggle();
  8.             });
  9.         });
  10.     </script>

This works with a Html.RenderAction on the _Layout page that gets the data from a Sql database to populate the treemenu,

All works ok, but when I click a link on the tree menu to render a new body content page the tree menu collapses.  Is there an easy way to add something that will maintain the tree menu state?

Please feel free to dumb down the response as this area really isn't my strong point!

Thanks