【问题标题】:best_in_place gem, view not displaying updated edit without page reloadbest_in_place gem,查看不显示更新的编辑而不重新加载页面
【发布时间】:2012-11-03 20:39:46
【问题描述】:

我将 best_in_place gem 添加到我的项目中,并且在页面重新加载发生之前更新不会生效。我可以在我的显示视图中看到它闪烁,但它需要重新加载页面。这是为什么呢?

我的列表控制器:

 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

我的列表显示视图-

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

我的 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

我的应用程序 js 清单 -

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

我的咖啡单-

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

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

这可能是我的清单 js 文件的顺序吗?我在这里忽略了什么以获取更新而无需重新加载页面?感谢您的关注。

【问题讨论】:

    标签: ruby-on-rails ajax controller best-in-place


    【解决方案1】:

    我只是忘记在列表控制器的顶部添加respond_to :json。感谢那些看过的人。

    【讨论】:

      猜你喜欢
      • 2018-11-15
      • 2013-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多