[英]Dynamic HTML Table With DataTable not paginating
我有一個按以下結構生成的html表:
echo "<table class='table table-striped table-inverse table-bordered table-hover' id='LeaderBoardTable' table_Dynamic >";
echo "<thead>";
echo "<tr>";
echo "<th></th>";
echo "<th>Username</th>";
echo "<th>SteamID</th>";
echo "<th>Score</th>";
echo "<th>K/D</th>";
//echo "<th>Search</th>"; //Do later
echo "</tr>";
echo "</thead>";
echo "<tbody id='leaderboardTable' class='leaderboardTable'>";
foreach ($items as $item){
$player = new Player($item['steam'], $dbh);
echo "<tr>";
echo "<td><i class='fa fa-crosshairs' aria-hidden='true'></i></td>";
echo "<td>" . $player->get("name") . "</td>";
echo "<td>" . $player->get("steam") . "</td>";
echo "<td>" . $player->get("score") . "</td>";
echo "<td>" . getKD($player) . "</td>";
echo "</tr>";
}
echo "</tbody>\n</table>";
該表加載正常,將其插入文檔的javascript如下所示:
$(document).ready(function() {
$.ajax({
type: 'post',
url: 'control/leaderboard/leaderboardGrab.php',
data: 'null=null',
}).done(function(d){
$('#loadArea').html(d);
$('#LeaderBoardTable').DataTable({
"order": [[3, "desc"]],
"bPaginate": true,
});
});
});
該表本身可以很好地加載,並且.DataTable()
函數“可以正常工作”,因為該表旁邊有用於排序的箭頭,並且搜索框和顯示的項目數都可以正常使用,但是分頁似乎不起作用盡管它確實出現並顯示正確的頁數。 當前它顯示[1] [2] [3] [4] [5] [...] [307],因此它的頁面數量確實合適,但是我無法單擊任何數字以轉到該頁面頁。 下面是整個頁面,該頁面調用生成代碼,並且所有文件調用都位於頭部。
<html>
<head>
<title> <?php echo $webTitle; ?> </title>
<?php $page = "leaderboards" //setting page for include ?>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Calling JS -->
<!-- Latest compiled and minified Jquery JavaScript -->
<script src="js/jquery.min.js"></script>
<script src="js/DataTable/jqueryDataTables.js"></script>
<script src="js/DataTable/dataTables.bootstrap4.min.js"></script>
<script src="js/bootstrap/bootstrap.min.js"></script>
<script src="js/leaderboard/leaderboardFunctions.js"></script>
<!-- Bootstrap 4 and Tether -->
<script src="js/tether/tether.min.js"></script>
<!-- Custom JS -->
<script src="js/Navjs.js"></script>
<script src="js/paging.js"></script>
<!-- End Of JS -->
<!-- Bootstrap 4, Tether, Fontawesome -->
<link rel="stylesheet" href="css/DataTable/dataTables.bootstrap4.css">
<link rel="stylesheet" href="css/tether/tether.min.css">
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css">
<link rel="stylesheet" href="css/fontawesome/font-awesome.min.css">
<link rel="stylesheet" href="css/social.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<?php include_once "views/social.php" ?>
<div class="container" style="width:95%;">
<div class="row">
<div class="wrapper">
<?php include_once "views/nav/index.php" ?>
<?php include_once "views/$page/index.php" ?>
</div>
</div>
</div>
</body>
</html>
任何想法為什么它不起作用? 90%的DataTables正常工作,但分頁無效,這似乎是唯一無法正常工作的部分。
我收到的僅控制台錯誤缺少Favicon.ico。
謝謝!
對我包含的文件進行了一些更改,我嘗試使用CDN,但除某些樣式外,它幾乎可以正常工作,因此我下載了與CDN和jquery-ui相同的文件,並添加並且似乎可以正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.