Twitter Bootstrap:重新加载当前选项卡 [英] Twitter Bootstrap: Reload Current Tab
问题描述
如何重新加载当前选择的Twitter Bootstrap选项卡?
How do you reload the currently selected Twitter Bootstrap tab?
到目前为止,这是我所拥有的,但这只会使随后的所有分页重新加载多次.
This is what I have so far, but it just makes any subsequent tabs reload multiple times.
function reload_tab() {
$('a[data-toggle="tab"]').on('shown', function (e) {
$('#tab-loaded-content').load($(e.target).attr('href'));
});
}
推荐答案
尝试一下
$('#tab-loaded-content').load($('li.active a[data-toggle="tab"]').attr('href'));
您正在做的是每次调用reload函数时,它将绑定到shown
事件(实际上并不存在)来重新加载该选项卡.调用两次,标签将重新加载两次.不是你想要的!
What you were doing is every time you call the reload function, it binds to the shown
event (didn't know that existed honestly) to reload that tab. Call it twice, tabs will reload twice. not what you want!
上面的一个衬里只是告诉它从链接的href
属性中加载内容,该属性是活动选项卡li.active
的子级.
The one liner above simply tells it to load the content from the href
attribute of the link that is a child of the active tab li.active
.
这篇关于Twitter Bootstrap:重新加载当前选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!