Viktor
Viktor

Reputation: 4346

Uncaught TypeError: $(...).slider is not a function with Bootstrap-Slider-Rails

I added gem 'bootstrap-slider-rails' into my Rails (4.1.8) project, but I'm getting an error Uncaught TypeError: $(...).slider is not a function when trying to call .slider() function on my input

application.js

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

application.scss

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

html

<div class='panel-body'>
  <span>10</span>
  <input class='span2' data-slider-min='1000' data-slider-step='5' data-slider-value='[250,450]' id='prices' type='text' value=''>
  <span>1000</span>
</div>

js

$(document).ready(function(){
  $("#prices").slider();
});

Where is my error?

Upvotes: 3

Views: 9091

Answers (1)

Viktor
Viktor

Reputation: 4346

Found a solution here https://github.com/seiyria/bootstrap-slider

If there is already a JQuery plugin named slider bound to the JQuery namespace, then this plugin will take on the alternate namespace bootstrapSlider.

So, you need to change

$("#prices").slider();

To

$("#prices").bootstrapSlider();

Upvotes: 2

Related Questions