Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
104
rated 0 times [  111] [ 7]  / answers: 1 / hits: 12825  / 11 Years ago, mon, january 20, 2014, 12:00:00

Hello I'm having some trouble trying to save the current selected tab when the page is reloaded,



I have a bootstrap 3.0 nav nav-tabs setup as my markup, like this:



<ul class=nav nav-tabs id=feedtab>
<li class=active id=atlasstab><a href=#atlass onclick=swapfeeds(1); data-toggle=tab>Atlass</a></li>
<li id=aviationtab><a onclick=swapfeeds(2); href=#avi data-toggle=tab>Aviation</a></li>
<li id=ittab><a onclick=swapfeeds(3); href=#proc data-toggle=tab>IT&S</a></li>
<li id=processingtab><a onclick=swapfeeds(4); href=#it data-toggle=tab>Plan&Proc</a></li>
</ul>


I am storing the lastactive variable into a cookie, the values are correct so it seems my jquery is incorrect, I'm simply trying to set the active tab to the corresponding 'lastactive' variable, IE : 1, 2, 3, 4



I'm aware that tab index starts at zero so i tried to increment the value +!, but still not working, can someone point out my problem?



this is the javascript im using to try set the active tab:



var lastactive = $.cookie(lastactive) != undefined ?  $.cookie(lastactive) : 1;

$(document).ready(function() {
$(#feedtab).tabs({active: lastactive + 1 });
});

More From » jquery

 Answers
14

Reworked bootstrap example : http://bootply.com/107082
You have to select the child from the cookie as a jquery object and then call .tab('show').


[#48545] Saturday, January 18, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackelyn

Total Points: 303
Total Questions: 103
Total Answers: 102

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
jackelyn questions
Thu, Apr 8, 21, 00:00, 3 Years ago
Sun, Feb 28, 21, 00:00, 3 Years ago
Mon, May 25, 20, 00:00, 4 Years ago
Thu, Apr 30, 20, 00:00, 4 Years ago
;