5

レール3.2.11

Gemfile:

gem 'jquery-rails'
gem "best_in_place"

aplication.js

//= require jquery
//= require jquery_ujs
//= require best_in_place

post.js.coffee

jQuery ->
  $('.best_in_place').best_in_place()

show.html.erb

<%= best_in_place @post, :title %>

インラインフォームが表示されましたが、js 例外が発生し、入力時に何も起動されず、フォーカスが緩んでいるなどのトレースバック:

Uncaught SyntaxError: Unexpected token u jquery.js:525
jQuery.extend.parseJSON jquery.js:525
BestInPlaceEditor.setHtmlAttributes best_in_place.js:265
BestInPlaceEditor.forms.input.activateForm best_in_place.js:309
BestInPlaceEditor.activate best_in_place.js:54
BestInPlaceEditor.clickHandler best_in_place.js:260
jQuery.event.dispatch jquery.js:3046
elemData.handle

jquery.js の行

if ( window.JSON && window.JSON.parse ) {
  return window.JSON.parse( data );

どうすればこれを修正できますか?

アップデートの問題が解決しました。同じ変更を行いますが、すべて正常に動作します。マジック ;)

4

2 に答える 2

3

私の場合、gemのgitバージョンを使用すると解決しました。

gem 'best_in_place', github: 'bernat/best_in_place'

于 2013-02-04T12:19:42.423 に答える
0

多分あなたは変わるべきです

jQuery ->
  $('.best_in_place').best_in_place()

jQuery ($) ->
  $('.best_in_place').best_in_place()
于 2013-01-22T19:51:44.167 に答える