0

I am using tabcontainer with three tabs.using css tabcontainer,not ajax tabcontainer.then i set automatic refresh of every one minute.now i select the tab2,but when page refresh it automatically go to tab1.so how to maintain the selected tab when page load or refresh,i want jquery.please help me.i am trying,tab click event i got tab selected index,then this value pass into page load,but not working,is any other way to keep selected tab when page load.cookies also try but no use,then hidden field used,but don't know how to this hidden value get from cs page.my code

<div id="Nav" class="tabNav" style="width: 80%; height: auto; float: left; margin-left: 8.9%;" onclick="pageload()">
    <ul class="tabNav" id="tab">
        <li><a href="#nogo" title="Address Info" linkrel="#tab-1">Address Info</a>
        </li>
        <li><a href="#nogo" title="Additional Info" linkrel="#tab-2">Additional Info</a>
        </li>
        <li><a href="#nogo" title="Payment &amp; Job Info" linkrel="#tab-3">Payment Info</a>
        </li>
        <li></li>
    </ul>
</div>

<div class="full" id="tab-1">//Some Dada</div>
</div>
<div class="full" id="tab-2">//Some Dada</div>
</div>
<div class="full" id="tab-3">//Some Dada</div>
palaѕн
  • 72,112
  • 17
  • 116
  • 136
user2235898
  • 39
  • 1
  • 9
  • var selected function pageload() { var $tabs = $('#Nav').tabs(); selected = $tabs.tabs('option','selected'); alert(selected); – user2235898 May 09 '13 at 12:05
  • whenever your are going to click the tab get that tab index and store it globally while reload the page get that tab index value and make it as selected. – Brijesh Eshwar May 09 '13 at 12:06
  • how to i got the value globally,that value save into button click event,how to that value pass into page load,so only i used cookies,but not use,any other way,thanks for your quick reply – user2235898 May 09 '13 at 12:11
  • Anyone know jquery means please reply me. – user2235898 May 09 '13 at 12:16

1 Answers1

0

Variables you set with JS won't exist across multiple pages. You could add a variable to the URI before you refresh, and use that to select the appropriate tab:

$("#Nav").bind('tabsselect', function(e, ui) {
    window.location.href = window.location.href + "?tab=" + ui.index;
});

...now, when you refresh the page you can search the URI for the tab variable and select the appropriate index. There is, of course, more in-depth URI checking you could do to ensure that you appropriately build your new window.location value.

Consider:

If you already explored the hidden field approach, assuming you're storing the index in the field, you can access the value with $('#hiddenFieldId').val() and set your tab via $('#Nav').tabs({ selected: $('#hiddenFieldId').val() });

Community
  • 1
  • 1
jterry
  • 6,209
  • 2
  • 30
  • 36
  • Is any possible to use cookie to get the value and pass into page load,page refresh also i done into jquery – user2235898 May 09 '13 at 13:51
  • You can use `jQuery-cookie` [to set and get cookies](http://stackoverflow.com/questions/1458724/how-to-set-unset-cookie-with-jquery), but you can also just use straight JS (also mentioned in that answer). – jterry May 09 '13 at 13:59