【发布时间】:2012-12-01 07:23:18
【问题描述】:
我正在使用 Rails 创建脚手架。 这是我的索引页
<%- model_class = Tasktodo -%>
<div class="page-header">
<h1><%=t 'title', :default => model_class.model_name.human.pluralize %></h1>
</div>
<table class="table table-striped">
<thread>
<tr>
<th><%= model_class.human_attribute_name(:id) %></th>
<th><%= model_class.human_attribute_name(:name) %></th>
<th><%= model_class.human_attribute_name(:tname) %></th>
<th><%= model_class.human_attribute_name(:created_at) %></th>
<th><%=t '.actions', :default => t("helpers.actions") %></th>
</tr>
</thead>
<tbody>
<div id="edit">
<% @tasktodos.each do |tasktodo| %>
<tr>
<td><%= link_to tasktodo.id, tasktodo_path(tasktodo) %></td>
<td><a href="#" onclick="inedit()" style="text-decoration:none"><%= tasktodo.name %></a></td>
<td><%= tasktodo.tname %></td>
<td><%=l tasktodo.created_at %></td>
<td>
</div>
<%= link_to t('.edit', :default => t("helpers.links.edit")),
edit_tasktodo_path(tasktodo), :class => 'btn btn-mini' %>
如果我单击编辑按钮意味着。它将转到编辑页面,如下一页.. 现在我想在没有服务器命中的情况下进行操作。意味着当我点击时不要进入下一页。 所有操作应仅在同一页面中完成。 使用Ajax,我该怎么做?
【问题讨论】:
-
您可以通过
inline editing或在索引页面中获取部分编辑表单,然后从那里更新。 -
这是一个开放式回答问题,有多种方法可以做到这一点。
标签: ruby-on-rails ajax scaffold