jquery-ui和Rails4

时间:2014-06-13 12:40:39

标签: javascript jquery-ui ruby-on-rails-4

我的应用程序中已经有几个javascript插件,它们可以查找(select2,bootstrap-datetimepicker,ckeditor,ace,chartkick)

尝试让jquery-ui运行以添加一些可排序的列表/表。

无法让Jquery-ui在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 %>

当我看到控制台时,我得到了:

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

2 个答案:

答案 0 :(得分:1)

看起来像'='符号的拼写错误,而不是'//' 改为

  //= require jquery.ui.all

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

答案 1 :(得分:0)

我认为应该是:

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