gpt4 book ai didi

javascript - 使用 jQuery 和插件使表格可排序

转载 作者:行者123 更新时间:2023-12-03 09:05:37 25 4
gpt4 key购买 nike

我正在尝试使我的表格可排序。这是目前的样子:

<table class="table table-bordered table-hover employement_request_panel tablesorter">
<thead>
<tr>
<th></th>
<th></th>
<th class="center">Name <i class="fa fa-angle-double-down"></i></th>
<th class="center">IQ <i class="fa fa-angle-double-down"></i></th>
<th class="center">Efficiency <i class="fa fa-angle-double-down"></i></th>
<th class="center">Focus <i class="fa fa-angle-double-down"></i></th>
<th class="center">Happiness <i class="fa fa-angle-double-down"></i></th>
<th class="center">Quality <i class="fa fa-angle-double-down"></i></th>
<th class="center">Salery <i class="fa fa-angle-double-down"></i></th>
</tr>
</thead>

<tbody>
<%Employe.where(company_id: company.id, request: true).each do |employe|%>
<tr>
<td class="center cd-popup-trigger popup1"><i style="color: green;" class="fa fa-check"></i></td>
<td class="center cd-popup-trigger popup2"><i style="color: red;" class="fa fa-close"></i></td>
<td class="center js-employee-name"><%=employe.name%></td>
<td class="center"><%=employe.iq%></td>
<td class="center"><%=employe.efficiency%></td>
<td class="center"><%=employe.focus%></td>
<td class="center"><%=employe.happiness%></td>
<td class="center"><%=employe.quality.capitalize%></td>
<td class="center"><%=employe.salery%></td>
<td class="js-employee-id" style="display:none;"><%=employe.id%></td>
</tr>
<%end%>
</tbody>
</table>

但我无法让它工作。我正在使用tablesorter尝试对我的 table 进行排序。我打电话<%= javascript_include_tag('jquery.tablesorter.min.js') %>和 jQuery,但我的表格不是不可排序的,或者至少我无法通过单击 <th> 让它们在 web 应用程序上排序的。我还添加了类(class) tablesorter到 table 上。

请让我知道如何完成这项工作。

最佳答案

看起来您错过了初始化:

    $(function() {
$('.tablesorter').tablesorter();
});

来自文档:

Start by telling tablesorter to sort your table when the document is loaded

关于javascript - 使用 jQuery 和插件使表格可排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32192793/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com