best_in_place gem初始化
轨道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
查看内联表单,但我得到了jsexception,并没有触发输入,松散焦点等追溯:
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 );
我怎么能解决这个问题?
upd问题解决了。 做同样的改变,但一切正常。 魔法 ;)
在我的情况下,使用gem的git版本解决了它。
gem 'best_in_place', github: 'bernat/best_in_place'
也许你应该改变
jQuery -> $('.best_in_place').best_in_place()
至
jQuery ($) -> $('.best_in_place').best_in_place()