0

https://github.com/bernat/best_in_placeのガイドに従ってい ます。アプリを実行すると、次のエラーが表示されます。これはどういう意味ですか?

%table
  - @schedules.each do |s|
    %tr
      %td= best_in_place s, :name

$(document).ready(function() {
  /* Activating Best In Place */
  jQuery(".best_in_place").best_in_place();
});

Uncaught TypeError: Object [object Object] has no method 'best_in_place'

4

4 に答える 4

1

まず、best_in_placegem が環境にインストールされ、JavaScript ファイルが HTML にインポートされていることを確認する必要があります。アセット パイプライン (Rails 3.1 以降) を使用している場合は、それを JavaScript マニフェストに含めることができます。

# app/assets/javascripts/application.js
//= require jquery
//= require jquery-ui
//= require best_in_place

best_in_class次に、スクリプトに、バインドして関数を実行できる HTML DOM 要素があることを確認します。

# in your view
<div class="best_in_class"></div>
于 2013-08-30T21:19:42.367 に答える
0

app/assets/javascripts/best_in_place.js を削除します

ビューにアクティブ化コードを含める:

%table
  - @schedules.each do |s|
    %tr
      %td= best_in_place s, :name
:javascript
$(document).ready(function() {
  /* Activating Best In Place */
  jQuery(".best_in_place").best_in_place();
});
于 2013-09-03T16:40:40.337 に答える
0

私は同じエラーを抱えていました。サーバーを再起動したところ、うまくいきました。

于 2013-11-25T21:52:16.343 に答える