best_in_place gem initializing

China☆狼群 提交于 2019-12-10 14:32:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!