best_in_place gem, view not displaying updated edit without page reload

霸气de小男生 提交于 2019-12-25 08:49:49

问题


I added the best_in_place gem to my project and the update does NOT take effect until a page reload has happened. I can see it flash in my show view but it requires a page reload. Why is this?

My Lists controller:

 respond_to :html, :xml, :js


  def update
    @list = List.find(params[:id])
    @list.update_attributes(params[:list])  
    respond_with(@list, :location => list_url(@list))
  end

My Lists show view-

  <h2 class="page-header"><%= best_in_place @list, :name %></h2>
  <h2 class="lead"><%= best_in_place @list, :description %></h2>

My gemfile-

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'best_in_place'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby
  gem 'jquery-ui-rails'
  gem 'uglifier', '>= 1.0.3'
end

My application js manifest -

//= require jquery
//= require jquery_ujs
//= require jquery.ui.datepicker
//= require justgage
//= require raphael.min
//= require jquery.purr
//= require best_in_place
//= require_tree .

My lists coffee-

jQuery ->
  $('#task_due_date').datepicker
    dateFormat: 'mm/dd/yy'

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

Could it be the order of my manifest js files? What am I overlooking here to get the update to take without a page reload? Thanks for your attention.


回答1:


I simply forgot to add the respond_to :json at the top of my lists controller. Thanks to those that took a look.



来源:https://stackoverflow.com/questions/13213293/best-in-place-gem-view-not-displaying-updated-edit-without-page-reload

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