Bootstrap shown.bs.tab事件不起作用 [英] Bootstrap shown.bs.tab event not working

查看:1057
本文介绍了Bootstrap shown.bs.tab事件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用灵活的模板(使用引导程序),而我无法使Tab上的show.bs.tab事件起作用.

I'm using the Flexy template (using bootstrap) and I can't get the shown.bs.tab event on tab to work.

我设法使其在 JSFiddle 上运行.

这是我在模板中使用的代码,该代码什么也没产生:

Here is the code I use in my template that produce nothing :

<div role="tabpanel">
  <ul class="nav nav-tabs" role="tablist">
    <li class="active"><a id="tab1" href="#chart1" role="tab" data-toggle="tab">Tab 1</a></li>
    <li><a id="tab2" href="#chart2" role="tab" data-toggle="tab">Tab 2</a></li>
  </ul>
  <div class="tab-content">
    <div class="tab-pane active" id="chart1">Tab 1 Content</div>
    <div class="tab-pane" id="chart2">Tabe 2 Content</div>
  </div>
</div>

<script>
  $(function() {
    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
      alert(e.target.href);
    })
  });
</script>

我想念什么?如果我将此代码复制/粘贴到Flexy代码上,将无法正常工作.有什么步骤可以了解出什么问题了?谢谢!

What can I miss ? If I copy/paste this code on the Flexy code it doesn't work. What are the steps to understand what is wrong ? Thanks !

推荐答案

问题更多是与Rails相关的问题.

最后,由于@KyleMit所说的原始模板中没有这个问题,因此我每一个代码都删除了一个代码.

I ended up by removing one by one every piece of code since the issue was not there in the raw template as @KyleMit says.

每当我从application.js文件中删除行//= require bootstrap-sprockets时,问题就会消失!

Whenever I remove the line //= require bootstrap-sprockets from my application.js file the issue disappears !

问题是我同时需要bootstrapbootstrap-sprockets.我只需要其中之一,但不要全部.

The issue was that I was requiring both bootstrap and bootstrap-sprockets. I should have require just one of them but not both.

这篇关于Bootstrap shown.bs.tab事件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆