如何将我的表单呈现到rails上的索引页ruby?

时间:2012-10-02 10:54:23

标签: ruby-on-rails ruby ruby-on-rails-3 jquery

我的index页面中有一个显示表格。我在同一页面中有一个new按钮。当我点击new按钮时,form应显示在表格网格顶部的同一index页面中。我怎样才能做到这一点?我是ROR的新手。所以请详细帮我。

这是我的索引页。

<div id="new_survey_link">
Create a
<%= link_to 'New', new_enr_rds_surv_rdsap_xref_path %>
</div>

<table class="gridView">
  <tr class="gridViewHeader">
  <th>Section</th>
  <th>Questions</th>
  <th>Answer</th>
  <th>Element</th>
  <th>Sub Element</th>
  <th>Material</th>
  <th>Action</th>
  </tr>

  <% if @enr_rds_surv_rdsap_xrefs.empty? %>
    <td class="empty_data" colspan="7">No Energy/Survey Cross references are currently exist.</td>
  <% else %>
  <% @enr_rds_surv_rdsap_xrefs.each do |survey| %>
  <tr class="<%= cycle('gridViewclickableRowDialog', 'gridViewAltclickableRowDialog') %>">
    <td><%= survey.Section %></td>
    <td><%= survey.enr_rds_question_2009.question_text %></td>
    <td><%= survey.Answer_No %></td>
    <td><%= survey.element.Element %></td>
    <td><%= survey.sub_element.Sub_Element %></td>
    <td><%= survey.renew_schedule.Material %></td>
    <td>
      <%= link_to 'Edit', '#', :remote => true, class: "create-user" %> | 
      <%= link_to 'Delete', survey, method: :delete,
                                 confirm: "Are you sure?" %>
    </td>
  </tr>
  <% end %>
  <% end %>
</table>

1 个答案:

答案 0 :(得分:1)

您可以添加页面中已有的表单并使用style =“display:none”隐藏它; 然后将“新”链接的click事件绑定到切换可见性的javascript。和jQuery一样,你可以使用onclick =“$('#new_survey_link a')。toggle();”

相关问题