best_in_place gem初始化

时间:2013-01-22 19:09:47

标签: ruby-on-rails best-in-place

rails 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 );

我怎么能解决这个问题?

更新问题解决了。做同样的改变但一切正常。魔术;)

2 个答案:

答案 0 :(得分:3)

在我的情况下,使用gem的git版本解决了它。

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

答案 1 :(得分:0)

也许你应该改变

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

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