链接到特定选项卡Bootstrap Codeigniter [英] Link to specific tab Bootstrap Codeigniter
本文介绍了链接到特定选项卡Bootstrap Codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用codeigniter,我有同样的问题的主题:
我尝试如下, sucess:
< ul class =nav nav-pill nav-stack>
< li class =<?php echo($ acao =='listar')?'active':'';?>>
< a href =#mytab1data-toggle =tab>
< i class =fa fa-cogs>< / i>& nbsp;姓名链接我的标签1
< / a&
< / li>
< li class =<?php echo($ acao =='cadastro')?'active':'';?>>
< a href =#mytab2data-toggle =tab>
< i class =fa fa-folder-open>< / i>& nbsp;名称链接我的标签2
< / a>
< / li>
< li class =<??php echo($ acao =='tipos')?'active':'';?>>
< a href =#mytab2data-toggle =tab>
< i class =fa fa-cogs>< / i>& nbsp;名称链接我的标签3
< / a>
< / li>
< / ul>
在页脚中:
< script type =text / javascript>
$(function(){
// Javascript启用链接到标签
var hash = document.location.hash;
if(hash){
console。 log(hash);
$('。nav-stack a [href ='+ hash +']')。tab('show');
}
更改页面重载的哈希
$('a [data-toggle =tab]')。on('show.bs.tab',function(e){
window.location.hash = e.target.hash;
});
});
< / script>
< script src =http://code.jquery.com/jquery.min.js>< / script>
< script src =<?php echo site_url('assets / js / jquery-1.10.2.min.js');?>>< / script&
< script src =<?php echo site_url('assets / js / jquery-migrate-1.2.1.min.js');?>>< / script&
< script src =<?php echo site_url('assets / js / jquery-ui.js');?>>< / script&
我也尝试过更改类中的类:
$('。nav-pills a [href ='+ hash +']')。tab('show');
并放在头上的javascript,但它不工作,我错了? >
解决方案
而不是
$('。nav-stacked a [href ='+ hash +']')
$('。nav-stack a [href ='+ hash +' ]')。show();
I'm using codeigniter and I'm having the same problem of the topic:
Link to specific tab Bootstrap
I'm trying as follows but to no sucess:
<ul class="nav nav-pills nav-stacked">
<li class="<?php echo ($acao == 'listar') ? 'active' : ''; ?>">
<a href="#mytab1" data-toggle="tab">
<i class="fa fa-cogs"></i> Name Link My tab 1
</a>
</li>
<li class="<?php echo ($acao == 'cadastro') ? 'active' : ''; ?>">
<a href="#mytab2" data-toggle="tab">
<i class="fa fa-folder-open"></i> Name Link My tab 2
</a>
</li>
<li class="<?php echo ($acao == 'tipos') ? 'active' : ''; ?>">
<a href="#mytab2" data-toggle="tab">
<i class="fa fa-cogs"></i> Name Link My tab 3
</a>
</li>
</ul>
In the footer:
<script type="text/javascript">
$(function() {
// Javascript to enable link to tab
var hash = document.location.hash;
if (hash) {
console.log(hash);
$('.nav-stacked a[href='+hash+']').tab('show');
}
// Change hash for page-reload
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
window.location.hash = e.target.hash;
});
});
</script>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="<?php echo site_url('assets/js/jquery-1.10.2.min.js'); ?>"></script>
<script src="<?php echo site_url('assets/js/jquery-migrate-1.2.1.min.js'); ?>"></script>
<script src="<?php echo site_url('assets/js/jquery-ui.js'); ?>"></script>
also I tried changing the class in line for:
$('.nav-pills a[href='+hash+']').tab('show');
and put in the head javascript, but it did not work, where I am wrong?
解决方案
Instead of $('.nav-stacked a[href='+hash+']').tab('show');
Try
$('.nav-stacked a[href='+hash+']').show();
这篇关于链接到特定选项卡Bootstrap Codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文