views:

107

answers:

1

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

+1  A: 

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?

jerone
I didn't realise that I needed the cookie plug-in in order for this work properly (doh!). I'd been bashing my head against the wall thinking my syntax was messed up when in fact I'd tried it the way you have it. I've downloaded the cookie plug-in and lo and behold it works perfectly. Many thanks
Istari