-->

best_in_place gem, view not displaying updated edi

2019-09-01 18:00发布

问题:

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.