正在调用Bootstrap Switch JS,但什么都不做

我正在使用bootstrap和jQuery,但我目前正在尝试添加Bootstrap Switch。 我开始采取行动,因为我无法让它发挥作用。 从检查元素看,js似乎没有修改任何html。

我试过使用gem或直js / css。 我从gem中尝试了sass和css。 不管它看起来像js什么也没做。 如果我删除bootstrap-switch js文件然后我得到一个错误(这是有道理的),所以我知道它被调用。 它什么都没做。

以下是我的设置:

gem

Using sass (3.3.2) Using bootstrap-sass (3.1.1.0) Using bootstrap-switch-rails (2.0.2) Using jquery-rails (3.1.0) Using sass-rails (4.0.1) 

Application.css.scss

 @import "bootstrap"; @import "bootstrap3-switch"; 

的application.js

 //= require jquery //= require jquery_ujs //= require bootstrap //= require bootstrap-switch // //= require_tree . 

other.js

 $("#famous-people-switch").bootstrapSwitch(); 

some.html.erb

 

Famous People:

尝试将代码包装在DOM ready handler $(function() {...}); 在执行jQuery代码之前确保正确加载所有DOM元素:

 $(function() { $("#famous-people-switch").bootstrapSwitch(); });