gpt4 book ai didi

javascript - 当应用程序构建在phonegap上时,一点点javascript将无法工作

转载 作者:行者123 更新时间:2023-12-03 08:31:06 27 4
gpt4 key购买 nike

所以我有一个使用 tablesorter 的基本应用程序,其中包括表格搜索以及表格信息的上下排序功能。

应用程序的第一页对于 tabelsorter 来说一切正常。但是,如果我导航到另一个页面,则只有向上和向下功能有效。即使每个页面上的编码相同,搜索也无法正常工作。

最初我被告知将 JS 编码放在页面底部,以便首先加载 DOM,但这仅修复了 table 上的上下功能(也不起作用)。

如何让搜索像在首页上一样工作?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">




<title>Anime Filler</title>
<link rel="stylesheet" href="css/jquery.mobile.min.css">
<link rel="stylesheet" href="css/style.css">


<script src="js/jquery.js"></script>
<script src="js/jquery.mobile.min.js"></script>
<script src="js/app.js"></script>
<script src="phonegap.js"></script>


<script src="js/jquery.tablesorter.js"></script>
<script src="js/widgets/widget-storage.js"></script>
<script src="js/widgets/widget-filter.js"></script>

</head>


<body>
<div data-role="page">

<div data-role="header" data-id="my-header" data-position="fixed">

<div id="head">
<center><a href="#" onclick='openURL("http://animefiller.com/")'><img id="headimg" src="logo.png" alt="" width="35" height="35" /></a></center>
</div>



</div>



<div id="main" data-role="main" class="ui-content">

</p>


<input class="search" type="search" data-column="0"> <br>

<table data-role="table" id="tablepress" class="tablesorter ui-responsive tablepress-id-24">
<thead>
<tr class="row-1 odd">
<th class="column-1 sorter-false"></th>
</tr>
</thead>
<tbody>
<tr class="row-2">
<td class="column-1"><div style="font-weight: bold; text-decoration: underline; font-size: large;">A</div></td>
</tr>
<tr class="row-3">
<td class="column-1"><a href="akatsuki-no-yona-yona-of-the-dawn.html">Akatsuki no Yona: Yona of the Dawn</a></td>
</tr>
<tr class="row-4">
<td class="column-1"><a href="assassination-classroom.html">Assassination Classroom</a></td>
</tr>
<tr class="row-5">
<td class="column-1"><a href="attack-on-titan-filler/">Attack on Titan</a></td>
</tr>
<tr class="row-6">
<td class="column-1"><div style="font-weight: bold; text-decoration: underline; font-size: large;">B</div></td>
</tr>

</tbody>
</table>


</div>





<div data-role="footer" data-id="my-footer" data-position="fixed">
<p style="text-align: center;"><span style="text-decoration: underline; color: #99cc00;"><a style="color: #99cc00; text-decoration: underline;" href="#" onclick='openURL("http://www.crunchyroll.com/affiliate_redirect/?widget=Tu017&amp;affiliate=af-46138-imyw")'><strong>Watch Anime Online</strong></a></span>
</div>


</div>

<script id="js">$(function() {

var $table = $('table').tablesorter({
theme: 'blue',
widgets: ["zebra", "filter"],
widgetOptions : {
// filter_anyMatch replaced! Instead use the filter_external option
// Set to use a jQuery selector (or jQuery object) pointing to the
// external filter (column specific or any match)
filter_external : '.search',
// add a default type search to the first name column
filter_defaultFilter: { 1 : '~{query}' },
// include column filters
filter_columnFilters: false,
filter_placeholder: { search : 'Search...' },
filter_saveFilters : true,
filter_reset: '.reset'

}
});
// make demo search buttons work
$('button[data-column]').on('click', function(){
var $this = $(this),
totalColumns = $table[0].config.columns,
col = $this.data('column'), // zero-based index or "all"
filter = [];

// text to add to filter
filter[ col === 'all' ? totalColumns : col ] = $this.text();
$table.trigger('search', [ filter ]);
return false;
});

});

</script>

<script>
$(document).ready(function()
{
$("#myTable").tablesorter();
}
);
</script>

<script>
function openURL(urlString){
myURL = encodeURI(urlString);
window.open(myURL, '_system');
}
</script>

</body>
</html>

最佳答案

要进行修复,我点击了此链接 https://stackoverflow.com/a/14469041/145346 @Mottie 提到并最终替换

$(document).ready(function() 

$(document).on('pageInit', function(){ })

在索引和新页面上

关于javascript - 当应用程序构建在phonegap上时,一点点javascript将无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33327613/

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