我之前使用过jquery-ui tabs
扩展通过ajax
加载页面片段,并隐藏或显示页面内部的隐藏div
。这两种方法都有很好的文档,我没有遇到任何问题。
然而,现在我想用选项卡做一些不同的事情。当用户选择一个选项卡时,应该重新加载整个页面 - 这样做的原因是每个选项卡部分的内容在渲染时有点昂贵,所以我不想一次性发送它们并使用切换"display:none"来显示它们。
我的计划是拦截选项卡的select
事件,并通过操作document.location函数重新加载页面。
在select
处理程序中,如何获取新选择的选项卡索引和相应的html LI对象?
$('#edit_tabs').tabs( {
selected: 2, // which tab to start on when page loads
select: function(e, ui) {
var t = $(e.target);
// alert("data is " + t.data('load.tabs')); // undef
// alert("data is " + ui.data('load.tabs')); // undef
// This gives a numeric index...
alert( "selected is " + t.data('selected.tabs') )
// ... but it's the index of the PREVIOUSLY selected tab, not the
// one the user is now choosing.
return true;
// eventual goal is:
// ... document.location= extract-url-from(something); return false;
}
});
有没有事件或ui对象的属性可以读取,以获取新选择的选项卡的索引、id或对象,或者其中的锚标签?
还是有更好的方法使用选项卡重新加载整个页面?