jQuery UI选项卡的保存状态 [英] Saving state of jQuery UI tabs

查看:102
本文介绍了jQuery UI选项卡的保存状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery UI 1.9,并且已经实现了演示页面上详细介绍的tabs小部件. PHP在选项卡内部动态提供数据.

I am using jQuery UI 1.9, and I've implemented the tabs widget pretty much as detailed on the demo page. PHP provides the data inside the tabs dynamically.

<script>

$(function()
    {
        $( "#tabs" ).tabs(
            {
                collapsible: true                   
            });
    });

</script>

<div id="tabs">

    <ul>
        <li><a href="#holdings">Holdings</a></li>
        <li><a href="#personal">Personal</a></li>
        <li><a href="#account">Account</a></li>
    </ul>

    <div id="holdings">
        blah blah blah
    </div>

    <div id="personal">
        blah blah blah
    </div>

    <div id="account">
        blah blah blah
    </div>

</div>

我的问题是-如何保存标签的状态?因此,如果我正在查看一个客户端,然后打开个人"标签,如何加载下一个客户端,并自动显示相同的标签?

My question is this - how can I save the state of the tabs? So if I'm looking at one client, and I open the 'Personal' tab, how can I load up the next client, and automatically be showing the same tab?

我在网上浏览了一下,以前的答案都指向使用cookie选项.测试失败和进一步的研究表明,此功能在1.9中已被弃用,所以我不确定是否还有办法做到这一点?

I've looked around the web, and previous answers point to using the cookie option. Failed testing and some further research suggest that this feature was deprecated in 1.9, so I'm not sure if there is even a way to do this anymore?

谢谢

推荐答案

似乎jQuery UI摆脱了使用最新实现维护状态的问题.

Seems like jQuery UI got rid of maintaining state with the latest implementation.

之前,使用jQuery标签在整个页面加载中保持状态非常简单.这是使用新代码执行此操作的一种可能方法.它仍然很容易,只是有些不同.

Before, it pretty simple to keep state across page loads with jQuery tabs. This is one possible way to do it with the new code. Its still pretty easy, just a little different.

$("#tabs").tabs({
    activate: function (e, ui) { 

    $.cookie('selected-tab', ui.newTab.index(), { path: '/' }); 

}, 
   active: $.cookie('selected-tab')  
});

这篇关于jQuery UI选项卡的保存状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆