Istari
Istari

Reputation: 3973

Jquery ui tabs - using ajax tabs AND cookie persistence

I'm a complete noob to jquery and jquery ui but have successfully implemented a couple of ajax tabs. I am now trying to combine this with the cookie persistence feature so that the page will open at the last opened tabe when returning to the page. Code for the ajax tabs looks like this:

<script type="text/javascript">
    $(function() {
        $("#tabs").tabs({

            ajaxOptions: {
                error: function(xhr, status, index, anchor) {
                    $(anchor.hash).html("Cannot load this tab at this time.");
                }
            }
        });
    });
    </script>

from the docs I get that the cookie persistence is invoked as follows:

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

Al my attempts at combining the two things ends up with the tabs not working at all. I'm still getting my head around the syntax used in ui and some help would be appreciated as I've been looking at this for too long now

Upvotes: 0

Views: 1387

Answers (1)

jerone
jerone

Reputation: 16871

This doesn't work ???:

<script type="text/javascript">
    $(function() {
        $("#tabs").tabs({
            ajaxOptions: {
                error: function(xhr, status, index, anchor) {
                    $(anchor.hash).html("Cannot load this tab at this time.");
                }
            },
            cookie: {
                // store cookie for a day, without, it would be a session cookie
                expires: 1
            }
        });
    });
</script>

And you also have the cookie plugin loaded?

Upvotes: 1

Related Questions