jquery - How to stay on active tab after refresh on page? -


i’ve designed tab page , followed instruction post: http://alexchizhov.com/pwstabs/

how stay on current tab when refresh page?

here code:

jquery(document).ready(function ($) {    $('.tabset0').pwstabs();    $('.tabset1').pwstabs({       effect: 'scale',       defaulttab: 3,       containerwidth: '600px'    });    $('.tabset2').pwstabs({       effect: 'slideleft',       defaulttab: 2,       containerwidth: '600px'    });    $('.tabset3').pwstabs({       effect: 'slidetop',       defaulttab: 3,       containerwidth: '600px'    });  }); 
<div class="content">     <div class="tabset0">         <div data-pws-tab="tab1" data-pws-tab-name="first tab">             first tab content         </div>         <div data-pws-tab="tab2" data-pws-tab-name="second tab">             second tab content         </div>         <div data-pws-tab="tab3" data-pws-tab-name="third tab">             third tab content         </div>     </div> </div> 

i appreciate if can shed light , me this.

i not cookie user might want share link,

instead add hashtag url tabid or something,

e.g : http://alexchizhov.com/pwstabs#tabid , javascript select right tab after identifying selected tab . ( routing )

though, if have no interest in letting user share link maybe saving data in localstorage / sessionstorage(for current tab only) / cookies might right solution u

** edit : **

to suggested solution above add js file whole pages contain tabs, lets call tabrouting.js, script following 1 ( wasn't tested though give idea ):

//url looking : mydomain.com/#tab=tabid (function($) {     var hashstring = window.location.href.split("#")[1];     if(hashstring)     {                    var tabid = hashstring.replace(/tab=/, "");          var tabitem = $("#" + tabid );         $(tabitem).addclass("selected");     } })(jquery) 

this code must run after tabs rendered . notice if planning of doing more use of hashtag string regex need enhanced.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -