当缓存保持禁用状态(即 cache: false
)时,如何防止选项卡再次加载远程内容?本质上,我想选择
一个选项卡,但不加载
它。
最佳答案
事实证明,您可以通过在每个选项卡的 anchor 元素中设置“cache.tabs”数据来控制每个选项卡的缓存。
我在另一篇文章中发布了答案:JQuery UI Tabs caching ,但我将在此处重新发布代码。
// disable cache by default
$("#tabs").tabs({
cache: false,
});
然后,在第一次加载选项卡内容后,您可以启用该选项卡的缓存。我只是将其放在 $(document).ready
中以便缓存页面:
$(document).ready(function () {
// cache content for the current tab
var currentTabIndex = $("#tabs").tabs('option', 'selected');
var currentTabAnchor = $("#tabs").data('tabs').anchors[currentTabIndex];
$(currentTabAnchor).data('cache.tabs', true)
});
关于ajax - jQuery UI 选项卡 : How to switch to a (ajax) tab without reloading it?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5254342/