I have a displaying table grid in my index
page. I have a new
button in the same page. When i click the new
button, the form
should appear in the same index
page at the top of the table grid. How can i do that? i am new to ROR. So please help me in detail.
Here is my index page.
<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>
You can add the form already in the page and hide it with style="display:none"; Then bind the click event of the "new" link to a javascript that toggles the visibility. like with jQuery you can have onclick="$('#new_survey_link a').toggle();"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.