Search code examples
javascriptjqueryruby-on-railsjquery-ui-slider

Jquery UI slider not visible in view - Ruby on rails


I have been trying to include jquery UI slider in my rails app (rails 4.2.1), but it is not visible when running the app on local host.

My application.js file:

//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree

application.css file:

 *= require jquery-ui
 *= require_tree .
 *= require_self

static.js file:

$('#slider').slider({
range: true,
values: [17, 67]
});

static/index.html.erb file:

<div id="slider"></div> <br/>

I'm new to rails and tried searching and applying different solutions, yet not able to figure out what's wrong. It will be great if I could get some help on how to make the slider visible?


Solution

  • I think this should be wrapped inside the ready event:

    $(document).ready(function(){
      $('#slider').slider({
        range: true,
        values: [17, 67]
      });
    });