问题
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 %>
inline form viewed but i got js exception and nothing fired on enter, loose focus etc. traceback:
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
lines at jquery.js
if ( window.JSON && window.JSON.parse ) {
return window.JSON.parse( data );
how i can fix this?
upd problem solved. do same changes but all works fine. magic ;)
回答1:
Using the git version of the gem resolved it in my case.
gem 'best_in_place', github: 'bernat/best_in_place'
回答2:
maybe you should change
jQuery ->
$('.best_in_place').best_in_place()
to
jQuery ($) ->
$('.best_in_place').best_in_place()
来源:https://stackoverflow.com/questions/14466158/best-in-place-gem-initializing