【问题标题】:How can i do this operation?on scaffolding我怎样才能做这个操作?在脚手架上
【发布时间】: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


【解决方案1】:

我能提供的最好的就是这个链接http://guides.rubyonrails.org/ajax_on_rails.html

按照它进行操作,您将能够使用 RoR 和 JQuery(使用 Ajax)构建 CRUD 支架

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-21
    • 2018-02-08
    • 1970-01-01
    • 2022-11-09
    • 2022-01-12
    相关资源
    最近更新 更多