Solved

JQuery - does not go to the selected tab after reloading the page

Posted on 2012-03-29
5
359 Views
Last Modified: 2012-03-31
I have used the following to store the selected tab "index" to the document.cookie, the document.cookie stores the correct selected tab index. However,  $('#tabs').tabs('select', document.cookie); is not working, does not go to the selected tab index.

Below is my codes, please advise

<script type="text/javascript">
$(function(){
      $('#tabs').tabs();
      $(document).ready(function() {
         // $('#tabs').tabs('select', $.cookie("tabNumber"));
       alert("document.cookie[" + document.cookie + "]");
         $('#tabs').tabs('select', document.cookie);   <== this one seems not to be corect

         $('#tabs').click(function() {
            var selected = $('#tabs').tabs('option', 'selected');
            document.cookie = selected;
           //$.cookie("myselectedtab", $tabs.tabs('option', 'selected'));
         });
      });
});
</script>
0
Comment
Question by:unistudent
  • 3
5 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 37781163
0
 

Author Comment

by:unistudent
ID: 37790701
I know EE Administrator. I have done all my work myself and asked for some questions I dont understand. I have honestly told my lecturer about asking some advice from here. they all say ok. I am not asking for people giving me codes.
0
 

Author Comment

by:unistudent
ID: 37790703
Dont know why it does not work i have read and tried based on http://jqueryui.com/demos/tabs/#cookie. anyway, i use document.cookie instead. it works.
0
 

Author Comment

by:unistudent
ID: 37790705
Thank you for your advice. gurvinder372Posted
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now