简体   繁体   English

Rails with bootstrap-slider-rails

[英]Rails with bootstrap-slider-rails

I'm trying to make an app in Rails 4 using bootstrap-slider-rails gem. 我正在尝试使用bootstrap-slider-rails gem在Rails 4中制作应用程序。

I can't find an example of how to use it. 我找不到如何使用它的例子。

I have set it up by installing the gem and adding: 我通过安装gem并添加以下内容进行设置:

@import 'bootstrap-slider';

to my application.css.scss file, and 到我的application.css.scss文件,和

//= require_tree .
//= require bootstrap-slider

bootstrap slider is the last thing required in my application.js bootstrap滑块是我的application.js中最后需要的东西

In my view, I want to make a slider. 在我看来,我想制作一个滑块。

I've tried crudely pasting the text shown on http://www.eyecon.ro/bootstrap-slider/ 我试着粗略地粘贴http://www.eyecon.ro/bootstrap-slider/上显示的文字

$('.slider').slider() $( '滑')。滑块()

although it does nothing except print the slider line as text. 虽然它除了将滑块线打印为文本外什么都不做。

How do you get this working? 你是如何得到这个工作的?

By contrast, when I use examples from 相比之下,当我使用的例子时

http://seiyria.com/bootstrap-slider/ http://seiyria.com/bootstrap-slider/

I can display a slider on the view. 我可以在视图上显示一个滑块。 I don't think this uses the gem though. 我不认为这会使用宝石。

Does anyone know how to get this working? 有谁知道如何使这个工作?

Please, show your browser console. 请显示您的浏览器控制台。 Verify if exists any errors and if your input text have class slider , like the following example: 验证是否存在任何错误,以及输入文本是否具有类slider ,如下例所示:

Gemfile: 的Gemfile:

gem 'bootstrap-slider-rails'

application.css: application.css:

 *= require bootstrap-slider
 *= require_tree .
 *= require_self

application.js 的application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap-slider

$(function() {
  $('.slider').slider();
});

test.html.erb: test.html.erb:

<input type="text" class="slider" value="" data-slider-min="-20" data-slider-max="20" data-slider-step="1" data-slider-value="-14" data-slider-orientation="vertical" data-slider-selection="after"data-slider-tooltip="hide">

I did a test, this way works. 我做了一个测试,这种方式有效。 Good luck 祝好运

Edit : Verify if your slider() call is in ready like $(function() { 编辑 :验证您的slider()调用是否已准备就绪,如$(function() {

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM