You can try to encode the url after your url just adds # and the fields should be displayed as
http://stackoverflow.com/questions/5727626
or
http://example.com/your_action
after that parse url
var fields = window.location.href.slice(window.location.href.indexOf('#') + 1).split(';');
and you will have the fields displayed.
Extending and collapsing will have to open the C # url at the end;
EDIT
here's how to do it: Demo
<ul> <li id='1'>Africa <ul> <li>Egypt</li> </ul> <ul> <li>SA</li> </ul> </li> <li id='2'>Asia <ul> <li>India</li> <li>China</li> <li>Japan</li> </ul> </li> <li id='3'>Europe <ul> <li>UK</li> <li>France</li> <li>Germany</li> </ul> </li> <li id='4'>America <ul> <li>US</li> <li>Mexico</li> <li>Argentina</li> </ul> </li> </ul>
Javascript
$(function () { $('li:has(ul)') .click(function () { var that = this; $('li:has(ul)').children().filter(':visible').parent().each(function (x) { if (this != that) toggle(this); }); $(this).children().toggle(); if (window.location.href.indexOf('#')>0){ var href = window.location.href.slice(0,window.location.href.indexOf('#')); }else{ var href = window.location.href } var ids ='' $('li:has(ul:visible)').each( function(){ ids=ids+$(this).attr('id')+';' } ); window.location = href +'#'+ids; }) .children().hide(); $('li:not(:has(ul))').css({ cursor: 'default', 'list-style-image': 'none' }); var fields = window.location.href.slice(window.location.href.indexOf('#') + 1).split(';'); for (var i in fields){ $('li#'+i).children().toggle(); } });
source share