admin管理员组文章数量:1278910
I'm trying to show a hidden tab only when needed. My current code looks like this:
<ul id="myTab" class="nav nav-tabs">
<li class="active"><a href="#home" data-toggle="tab">Home</a></li>
<li><a href="#data" data-toggle="tab" style="display:none;">New Tab</a></li>
</ul>
jquery:
$('#data').load('functions/test_function.php', { method: "example"}, function() {
$('#data').tab('show');
// $('#data').show();
})
Any idea what I'm doing wrong? The tab is never displayed after the code pletes.
I'm trying to show a hidden tab only when needed. My current code looks like this:
<ul id="myTab" class="nav nav-tabs">
<li class="active"><a href="#home" data-toggle="tab">Home</a></li>
<li><a href="#data" data-toggle="tab" style="display:none;">New Tab</a></li>
</ul>
jquery:
$('#data').load('functions/test_function.php', { method: "example"}, function() {
$('#data').tab('show');
// $('#data').show();
})
Any idea what I'm doing wrong? The tab is never displayed after the code pletes.
Share Improve this question asked Jul 31, 2012 at 14:12 user1216398user1216398 1,96013 gold badges33 silver badges41 bronze badges1 Answer
Reset to default 8With that provided code you are trying to display the tab content, and even that will not work.
As stated in the doc
each tab needs to be activated individually
And it needs to be activated on the data-toggle="tab"
element, not the content.
$('#data').load('functions/test_function.php', { method: "example"}, function() {
var $tab = $('[data-toggle="tab"][href="#data"]');
// OR var $tab = $('#tabID');
$tab.click(function(e) { // Binding for later use (for user interaction)
e.preventDefault();
$tab.tab('show');
});
$tab.show(); // Display the tab
$tab.tab('show'); // Display the content
})
You can choose to keep the explicit selector [data-toggle="tab"][href="#data"]
or set an id="tabID"
on the hidden tab.
本文标签: javascriptHow do I hide and show twitter bootstrap tabsStack Overflow
版权声明:本文标题:javascript - How do I hide and show twitter bootstrap tabs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741235915a2363007.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论