jQuery Tab 正在缓存 TabID
我这样定义了 jQuery 选项卡:
$('#serviceTabs').tabs({
idPrefix: 'ui-subtabs-',
spinner: 'Retrieving data...',
cache: false,
select: function(event, ui) {
if(checkServiceTabs(ui.index))
{
$('#ui-subtabs-'+(currentDetailTab+1)).html(" ");
currentDetailTab = ui.index;
return true;
}
else
return false;
},
collapsible: true
});
不幸的是,在重新加载页面后,选项卡的索引逐渐增加。 因此,在第一次请求时,我的 TabID 看起来像:
#ui-subtabs-1, #ui-subtabs-2, #ui-subtabs-3
重新加载页面后,它看起来像:
#ui-subtabs-4, #ui-subtabs-5, #ui-subtabs-6
副作用是,选项卡在重新加载后被锁定。 select 事件不再起作用。
仅供参考:选项卡位于 DIV 中,并与 $.get
函数合并。 所以我不重新加载整个页面,而只重新加载 div。
在新请求之前,我已经用 .html(" ")
空白了 div,并且我也尝试过
$('#serviceTabs').tabs("destroy");
有人知道如何删除 TabID 缓存吗?
I defined my jQuery tabs like this:
$('#serviceTabs').tabs({
idPrefix: 'ui-subtabs-',
spinner: 'Retrieving data...',
cache: false,
select: function(event, ui) {
if(checkServiceTabs(ui.index))
{
$('#ui-subtabs-'+(currentDetailTab+1)).html(" ");
currentDetailTab = ui.index;
return true;
}
else
return false;
},
collapsible: true
});
Unfortunately after reloading my page the index of my tabs is raised incrementally.
So on first request my TabID's look like:
#ui-subtabs-1, #ui-subtabs-2, #ui-subtabs-3
after reloading my page it looks like:
#ui-subtabs-4, #ui-subtabs-5, #ui-subtabs-6
The side effect is, that the tabs are locked after reload. The select event doesn't work anymore.
FYI: The tabs are in a DIV and merged with $.get
function.
So i don't reload the whole page but only the div.
Before the new request I already blank the div with .html(" ")
and I also tried
$('#serviceTabs').tabs("destroy");
Does anybody have an idea how to delete the TabID cache ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,TabID 所来自的
tabIndex
变量被封装在 Tabs 插件的匿名函数中,使其对外界完全不可见。它只是递增,并且插件没有提供重置它的方法。即使销毁插件的实例也无济于事。不过,在插件文档的概述页面上,指定可以使用选项卡容器进行引用用作选项卡按钮的
元素的 Title 属性。
然后,您将为选项卡按钮添加这种标记:
这将创建标题为 ID 的选项卡容器(用下划线替换空格):
然后,您必须相应地修改您的选择方法。
Unfortunately, the
tabIndex
variable from which the TabID is coming from is encapsulated in the anonymous function of the Tabs plugin, making it totally invisible to the outside world. It is only incremented and the plugin offers no method to be able to reset it. Even destroying the instance of the plugin would not help.On the overview page of the plugin's documentation though, it is specified that the tab containers can be references using the Title attribute of the
<a>
elements serving as tab buttons.You would have then this kind of markup for the tab buttons:
This will create tab containers with the title as ID (replacing spaces with underscores):
You would have then to modify you select method accordingly.