我正在使用footable。但是在呈现表单时搜索功能不起作用,我在下面包含了文件。
控制器
def leave_summary
if params[:summary].present?
@leave_summary = LeaveTaken.where(:teacher_id => params[:summary])
render :partial => "leave_detail"
end
end
查看 (leave_summary.html.erb)
<i class='icon-list'> Leave Summary</i>
<% end %>
</li> <% content_for :sidebar do %>
<ul class="nav nav-tabs nav-stacked">
<li>
<%= link_to "Leave management", "#", {class: 'text-center', style: "background-color:#c4c4c4;" } %>
</li>
<li>
<%= link_to new_leave_type_path do %>
<i class='icon-list'> Add Leave Type</i>
<% end %>
</li>
<li>
<%= link_to new_leave_apply_path do %>
<i class='icon-list'> Apply Leave</i>
<% end %>
</li>
<li>
<%= link_to leave_applies_path do %>
<i class='icon-list'> Leave Approval</i>
<% end %>
</li>
<li>
<%= link_to leave_summary_path do %>
<li>
<%= link_to my_leave_path do %>
<i class='icon-list'> My Leave</i>
<% end %>
</li>
</ul>
<% end %>
<div class='row-fluid clear'>
<div class='box gradient'>
<div class='title'>
<h3 style='margin-left:1em'>My Leave</h3>
</div>
<div class='content'>
<div class="control-group string optional student_gender">
<label class="string optional control-label" for="student_gender">Teacher Code</label>
<div class="controls">
<%= select_tag "leaves", options_from_collection_for_select(Teacher.all, "id", "teacher_code"), :prompt => "--Select Employee No--" %>
</div>
</div>
<div id = "leaves_apply">
</div>
</div>
</div>
</div>
_leave_detail.html.erb
<p class='pull-right'>
Search: <input id="filter" type="text">
</p>
<table class='footable' data-page-navigation=".pagination" data-filter="#filter" data-page-size="10" data-page-previous-text="prev" data-page-next-text="next">
<thead>
<tr class ="info">
<th>Leave Type</th>
<th>Leave Entitled</th>
<th>Leave Taken</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
<% @leave_summary.each do |i| %>
<tr class = "info">
<td><%= i.leave_type.leave_name %></td>
<td><%= i.leave_type.leave_count %></td>
<td><%= i.leave_type.leave_count - i.leave_balance %></td>
<td><%= i.leave_balance.to_i %></td>
</tr>
<% end %>
</tbody>
</table>
此处 Fotable 搜索不起作用。