我无法在我的应用程序中运行引导开关。
在我的gemfile中,我有
gem 'bootstrap-switch-rails', '~> 3.0.0'在我的application.html.haml中我有(我放了一个断点:它在加载后执行)
:javascript
$(function() {
$('input:checkbox').bootstrapSwitch();
});在我的application.css中
*= require_directory .
*= require_self
*= require_directory ./../fonts
*= require bootstrap3-switch在我的application.js中
//= require bootstrap
//= require bootstrap-switch
//= require turbolinks
//= require_tree .最后,在我的视图代码中,我有以下3次尝试:
= form_for(group) do |g|
= g.label :is_private, "is_private"
= g.check_box :is_private, :data => { :size=>'small', 'on-color'=>'success', 'on-text'=>'YES', 'off-text'=>'NO' }
%input{ :type => "checkbox", :name => "mycheckbox" }
.switch{ "data-on" => "primary", "data-off" => "info"}
%input{ :type => "checkbox" }结果总是一个标准的复选框。
有人能建议我哪里错了吗?
发布于 2015-02-18 20:20:58
嗯,我解决了,但我不确定这是不是正确的方法。
我需要插入以下几行
:javascript
$(function() {
$('input:checkbox').bootstrapSwitch();
});转换成我想要使用开关的任何.html.haml文件。
这对我来说似乎很奇怪,因为我已经在application.html.haml端插入了相同的代码,这应该足够了。
如果有更好的建议,请把它贴出来。
https://stackoverflow.com/questions/28567192
复制相似问题