You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:项目中使用Footable时分页功能无法正常工作,求解决

Troubleshooting Your FooTable Pagination Issue

Hey there! Let's walk through fixing your FooTable pagination problem step by step—there are a few clear issues in your code that are likely causing the failure:

1. Duplicate Pagination Scripts

You're loading both footable.paging.js and footable.paging.min.js at the same time. This creates conflicts because the same plugin code is being initialized twice. Remove one of them—stick with the minified version (footable.paging.min.js) for better performance.

2. Mismatched Column Counts

Your table's <thead> has 4 <th> elements, but each <tr> in <tbody> has 5 <td> elements. FooTable relies on strict table structure consistency, and this mismatch will break core features like pagination. Fix this by updating your header to match the data columns:

<thead>
<tr>
<th>Country</th> <!-- Add this to match the first td in your rows -->
<th data-hide="phone">Languages</th>
<th data-hide="phone">Population</th>
<th data-hide="phone">Median Age</th>
<th data-hide="phone">Area (Km²)</th>
</tr>
</thead>

3. Redundant Initialization Code

You’ve nested $(document).ready() inside another $(document).ready()—this is unnecessary and can cause unexpected behavior. Simplify your initialization to a single block:

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

(Note: $(function() { ... }) is shorthand for $(document).ready())

4. Verify Local File Paths

Double-check that your local CSS/JS files (like css/footable.core.min.css or js/footable.js) are actually located in the paths you’ve specified. A missing file (showing as a 404 error in your browser’s dev tools) will prevent FooTable from loading properly.

Corrected Full Code Example

Here’s your code with all the fixes applied:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/footable.core.min.css">
<link rel="stylesheet" type="text/css" href="css/footable.metro.css" />
<link rel="stylesheet" type="text/css" href="css/footable.paging.css"/>

<table id="example" class="footable" data-filter="#filter" data-page-size="5">
<thead>
<tr>
<th>Country</th>
<th data-hide="phone">Languages</th>
<th data-hide="phone">Population</th>
<th data-hide="phone">Median Age</th>
<th data-hide="phone">Area (Km²)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Australia</td>
<td>English 79%, native and other languages</td>
<td>23,630,169</td>
<td>37.3</td>
<td>7,739,983</td>
</tr>
<!-- Insert your remaining 100+ rows here -->
</tbody>
</table>

<script type="text/javascript" src="js/footable.js"></script>
<script type="text/javascript" src="js/footable.paging.min.js"></script>

<script>
$(function () {
  $('.footable').footable();
});
</script>

Extra Troubleshooting Step

If pagination still doesn’t work after these fixes:

  • Open your browser’s developer tools (F12) and check the Console tab for errors. 404s mean files are missing, while syntax errors point to other code issues.
  • Confirm your FooTable version is compatible with jQuery 3.2.1—most modern FooTable versions support this, but double-check if you’re using an older release.

内容的提问来源于stack exchange,提问作者Cs Student

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:24:53