5

导轨 3.2.11

宝石文件:

gem 'jquery-rails'
gem "best_in_place"

应用程序.js

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

post.js.coffee

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

显示.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 );

我该如何解决这个问题?

upd问题解决了。做同样的改变,但一切正常。魔法 ;)

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 回答