user3565039
user3565039

Reputation: 185

jquery-ui and Rails4

I have several javascript plugins in my app already and they work find (select2, bootstrap-datetimepicker, ckeditor, ace, chartkick)

trying to get jquery-ui running to add some sortable lists/tables.

Can't get Jquery-ui running in a rails 4 app...

# Gemfile
gem 'therubyracer', platforms: :ruby 
gem 'jquery-rails'                        
gem 'jquery-ui-rails'
gem 'non-stupid-digest-assets', '~> 1.0.4'

# app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
// = require jquery.ui.all

# app/views/rates/show.html.erb
<ul id="rates">
<% @plan.rate_items.each do |rate| %>
  <%= content_tag_for(:li, rate) do %> 
    <%= rate.name %>
  <% end %>
<% end %>
</ul>

<%= content_for :page_javascript do %>

<script>
$(document).ready(function(){
    $("#rates").sortable();
});

</script>
<% end %>

When I look at the console I just get:

TypeError: $(...).sortable is not a function

Upvotes: 0

Views: 541

Answers (2)

Rockwell Rice
Rockwell Rice

Reputation: 3002

Looks like a typo with the '=' sign not touching ' //' Change to

  //= require jquery.ui.all

http://guides.rubyonrails.org/asset_pipeline.html

Upvotes: 1

Florian Widtmann
Florian Widtmann

Reputation: 514

i think it should be:

# app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require jquery.ui.all
//= require_tree .

Upvotes: 0

Related Questions