A short, mock-independent way to do this with localStorage :
$("#tabs").tabs({ active: localStorage.getItem("currentIdx"), activate: function(event, ui) { localStorage.setItem("currentIdx", $(this).tabs('option', 'active')); } });
A layout-specific way to do this using custom data attributes (perhaps useful if attribute values ββwere to be used somehow in another place in your script).
jQuery UI:
$("#tabs").tabs({ active: localStorage.getItem("currentTabIndex"), activate: function(event, ui) { localStorage.setItem("currentTabIndex", ui.newPanel[0].dataset["tabIndex"]); } });
HTML layout example:
<div id="tabs"> <div id="tabs-1" data-tab-index="0"> tab 1 stuff... </div> <div id="tabs-2" data-tab-index="1"> tab 2 stuff... </div> <div id="tabs-3" data-tab-index="2"> tab 3 stuff... </div> </div>
lifetimes Mar 03 '15 at 12:16 2015-03-03 12:16
source share