[英]rails 5 best in place only updating some <li>s
这很奇怪。 我将“最佳位置” 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 .
这是我的office.coffee文件:
jQuery ->
$('.best_in_place').best_in_place()
如果您需要更多信息,如果我错过了明显的内容或已解决问题,请告诉我。 SOS。
好,修复它。 我以前的一个过滤器出现了问题。 对不起那个人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.