简体   繁体   English

JQuery UI选项卡在页面重新加载时不会保存选定的选项卡索引

[英]JQuery UI tabs wont save selected tab index upon page reload

When I use AJAX or PHP POST the page reloads and the tabs bounce back to index position 0, which is quite annoying. 当我使用AJAX或PHP POST时,页面重新加载并且标签弹回到索引位置0,这非常烦人。 You can find the code below. 你可以在下面找到代码。 I am trying to save the tab index in a cookie and use it to return to the selected tab even after the page reloads. 我试图将选项卡索引保存在cookie中,并使用它返回到选定的选项卡,即使页面重新加载。

The code is here: 代码在这里:

$(function() {
    $( "#tabs" ).tabs().find( ".ui-tabs-nav" ).sortable({ axis: "x" });
    $(document).ready(function() {
       $( "#tabs" ).tabs('select', $.cookie("tabNumber"));

       $( "#tabs" ).click(function() {
         $.cookie("tabNumber", $( "#tabs" ).tabs('option', 'selected'));
       });
    });
});

Maybe someone can help me to find out how to make it work? 也许有人可以帮我找到如何使它工作?

http://docs.jquery.com/UI/Tabs#option-cookie http://docs.jquery.com/UI/Tabs#option-cookie

Initialize a tabs with the cookie option specified. 使用指定的cookie选项初始化选项卡。

$( ".selector" ).tabs({ cookie: { expires: 30 } });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM