为什么 jQuery Tablesorter 插件不能在此 Wordpress 页面上工作?
我在此测试页面上有一个 Wordpress/jQuery 插件的工作示例: http://beerlyrics.com/jimmy -jones/
我将其硬编码到此页面的标题中,分页和过滤机制都正常工作。
我已将其转换为新页面,现在使用 wp_enqueue 来调用我的所有脚本,因为它应该完成: http://farmball.com/boston/boston-red-sox /red-sox-roster/
为什么分页和过滤机制不再起作用?
我已经确认它与 Firebug 中出现的 #baseball-table not Defined 错误和 audiplayer 错误无关。两个站点上都出现#baseball-table 错误,我停用了导致音频播放器错误的插件,这对插件性能没有影响。
下面是js初始化的代码:
jQuery(document).ready(function($) {
$("#baseball-table").tablesorter({ debug: false, sortList: [[0, 0]], widgets: ['zebra'] })
.tablesorterPager({ container: $("#pager"), positionFixed: false })
.tablesorterFilter({ filterContainer: $("#filter-box"),
filterClearContainer: $("#filter-clear-button"),
filterColumns: [0, 1, 2, 3, 4, 5, 6, 7, 8],
filterCaseSensitive: false
}); });
I have a working example of the Wordpress/jQuery plugin on this test page: http://beerlyrics.com/jimmy-jones/
I hardcoded it into the header on this page and both the pagination and filter mechanisms work correctly.
I have converted this over to a new page and am now using wp_enqueue to call all my scripts as it is supposed to be done:
http://farmball.com/boston/boston-red-sox/red-sox-roster/
Why wouldn't the pagination and filter mechanisms no longer work?
I have confirmed that it has nothing to do with a #baseball-table not defined error and an audiplayer error that comes up in Firebug. The #baseball-table error is occurs on both sites and I deactivated the plugin causing the audioplayer error and it made no difference to plugin performance.
Here is the code for js initialization:
jQuery(document).ready(function($) {
$("#baseball-table").tablesorter({ debug: false, sortList: [[0, 0]], widgets: ['zebra'] })
.tablesorterPager({ container: $("#pager"), positionFixed: false })
.tablesorterFilter({ filterContainer: $("#filter-box"),
filterClearContainer: $("#filter-clear-button"),
filterColumns: [0, 1, 2, 3, 4, 5, 6, 7, 8],
filterCaseSensitive: false
}); });
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试 jQuery.noConflict?
Try jQuery.noConflict?
我聘请了一名开发人员来解决这个问题。奇怪,但解决方法是 FTP 中的一个 js 文件的开头缺少 ( ,尽管 cPanel 在文件开头显示了它。我使用 cPanel 并且不知道它丢失了。
I hired a developer to fix this. Strange but the fix was that there was a missing ( at the beginning of one of the js files in FTP though cPanel showed it at the beginning of the file. I use cPanel and didn't know it was missing.