我有edit.js.erb:
$('#danswerform_<%= @danswer.id %>').hide().after('<%= j render("form") %>');
更新.js.erb:
$('#edit_danswer').remove();
$('#danswerform_<%= @danswer.id %>').show();
和编辑表格<%= form_for(@danswer, remote: true) do |f| %>
但是当我确认发生重新加载的更改时。(然后我按编辑好了)
控制器:
def update
@danswer = Danswer.find(params[:id])
respond_to do |format|
if @danswer.update_attributes(params[:danswer])
format.html { redirect_to danswers_path, notice: 'Danswer was successfully updated.' }
format.js
else
format.html { render action: "edit" }
end
end
end