views:

25

answers:

1

This is probably more simple than I'm making it but I just can't figure out how to do it. What I've got are tabbed sections created in Coldfusion. The output is that the selected section has a class name that contains the string "tab_selected (+ the UUID created in coldfusion)" versus the unselected tab sections whose class names contain the string "tab_unselected (+ the UUID created in coldfusion)". When you click on the unselected tabs the class is changed to "tab_selected (+ the UUID)" and all the other tabs are set accordingly.

What I'm attempting to do is, using javascript, when you exit the page it searches for the element that has the class that contains the string "tab_selected" and then sets the cookie with the id of that element...

This is all I have at this point (in JQuery)...And it could be terribly wrong. Please help.

        $(window).unload( function () {
        $("selector[name*='tab_selected_text']").cookie("TABS_REMEMBER", 1, { expires: null });
        });
+1  A: 

Since you're using jquery and its cookie plugin, it's very easy and automatic.

When you declare your tabs use this:

<script type="text/javascript">
  $(function () {
    $("#tabs").tabs({
      cookie: {
        // store cookie for a day, without, it would be a session cookie
        expires: 1
      }
    });
  });
</script>

It will cause to tabs component memorize the last used tab.

madeinstefano