【问题标题】:rails 5 best in place only updating some <li>srails 5 best in place 只更新一些 <li>s
【发布时间】:2017-03-25 14:06:32
【问题描述】:

这很奇怪。我将“就地最佳” gem 与无序列表结合使用,每个列表项都包括“就地最佳”助手。列表中的第一项工作正常,但后续列表项有问题。这是我部分(views/_dash.html.erb)中的代码:

<table class = 'table-hover'>
<li>


    <tr>
        <th class = 'name'> <%= best_in_place offer, :plan_name, :type => :input %> </th>
        <th class = 'name'> <%= best_in_place offer, :price, :type => :input %> </th>
        <th class = 'bids'> Bids(<%= @user.active_bids.count %>) </th>
    </tr>

</li>

以及相关视图中的代码:

<ul class = "offers">
  <%= render @offers %>
</ul>

<%= will_paginate %>

列表中的第一项工作正常。每个字段都显示正确的信息,是可编辑的,并且编辑保留在数据库中。第二项显示正确的字段,可编辑,更新信息。但是,刷新后,字段将恢复为原始值,不包括所做的编辑。列表中的其他项目最初显示正确的字段,但有些不可编辑,有些可编辑但不更新信息,有些可编辑但编辑的信息不会保留。 这是关联控制器的代码:

def update
@user = current_user
@offer = Offer.find params[:id]
if @offer.update_attributes!(offer_params)
  respond_to do |format|
    format.html { redirect_to( @offer )}
    format.json { render :json => @offer }
  end
else
  respond_to do |format|
    format.html { render :action  => :show } # edit.html.erb
    format.json { render :nothing =>  true }
  end
end

def dash
@user = current_user
@offers = current_user.offers.paginate(page: params[:page])
respond_to do |format|
  format.html
  format.json {render :json => @offer}
end

我的 application.js 看起来像这样:

//= require jquery
//= require jquery.purr
//= require best_in_place
//= require 'rest_in_place'
//= require jquery_ujs
//= require best_in_place.jquery-ui
//= require bootstrap
//= require turbolinks
//= require_tree .

这是我的 offer.coffee 文件:

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

如果您需要更多信息,如果我遗漏了一些明显的东西,或者是否有修复,请告诉我。求救。

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-5 best-in-place


    【解决方案1】:

    好的,解决了。这是我之前的一个过滤器的问题。对不起那些人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-15
      • 2013-01-25
      • 2012-10-28
      • 1970-01-01
      相关资源
      最近更新 更多