简体   繁体   中英

Rails with bootstrap-slider-rails

I'm trying to make an app in Rails 4 using bootstrap-slider-rails gem.

I can't find an example of how to use it.

I have set it up by installing the gem and adding:

@import 'bootstrap-slider';

to my application.css.scss file, and

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

bootstrap slider is the last thing required in my 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/

$('.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/

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:

Gemfile:

gem 'bootstrap-slider-rails'

application.css:

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

application.js

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

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

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() {

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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