Trouble with jQuery UI Tabs & Cookie Option

别说谁变了你拦得住时间么 提交于 2019-12-06 08:19:31

Okay, nevermind. I figured it out. Here's the new, working code:

<div id="selector" class="ui-mainColTabs">
    <ul>
        <li><a href="#tabs-1">Tab 1</a></li>
        <li><a href="#tabs-2">Tab 2</a></li>
    </ul>
    <div id="tabs-1"></div>
    <div id="tabs-2"></div>
</div>

<form id="form">
    <input type="submit" value="Kill" />
</form>

<a href="#" id="getCookie">Get</a>

<script type="text/javascript">
<!--
$(document).ready(function() {
    $("#selector").tabs({
        cookie: {
            name: 'tab_cookie',
            expires: 7
        }
    });
    $(".ui-tabs-nav, .ui-tabs-nav > *")

    $('#getCookie').click(function() {
        alert($.cookie('tab_cookie'));
    });

    $('#form').submit(function() {
        $.cookie('tab_cookie', null);
    });
});
//-->
</script>

The issue was that I couldn't figure out how to identify the cookie I was trying to work with. But just out of sheer dumb luck, I tried plugging in a "name" option. Kind of frustrating that jqueryui.com doesn't mention anything about that. Hopefully this may help someone else with the same problem.

So I guess it turns out I'm Obi-Wan. Go me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!