Javascript - yadcf 过滤器 OnClick 事件在以下情况后不起作用:
- 10 行条目之后
- 在这种情况下:您加载 html 页面,在 1-10 个条目之间有 X1 标记,在 10 个条目之后有 X2 标记。如果您通过 X 使用 onclick 事件过滤进行过滤,则:如果您使用 onclick 事件,则 X1 标记有效,但如果您使用 onclick 事件,则 X2 无效,因为在加载时 X2 最初是有效的页面 html,超过 10 个条目
这是我的 JavaScript 代码:
var oTable;
$(document).ready(function(){
oTable = $('#example').dataTable().yadcf([
{column_number : 0},
{column_number : 3, filter_type: "range_number_slider", filter_container_id: "external_filter_container"},
{column_number : 2, text_data_delimiter: ",", filter_type: "auto_complete"},
{column_number : 1, text_data_delimiter: ",", filter_type: "auto_complete"},
{column_number : 4, column_data_type: "html", html_data_type: "text", filter_default_label: "Select tag", filter_type: "auto_complete"}]);
$(".label.lightblue" ).on( "click", function() {
yadcf.exFilterColumn(oTable, [[4, $(this).text()]]);
});
$(".label4.lightblue4" ).on( "click", function() {
yadcf.exFilterColumn(oTable, [[4, $(this).text()]]);
});
$(".label2.lightblue2" ).on( "click", function() {
yadcf.exFilterColumn(oTable, [[2, $(this).text()]]);
});
});
jsfiddle 上的实时示例:http://jsfiddle.net/chcLmmps/
最佳答案
标签(标签)是动态添加的,因此它们没有附加事件。使用 .on
而不是 .click()
像这样。
$('#example').on('click',".label.lightblue", function () {
alert('onclick label');
yadcf.exFilterColumn(oTable, [
[4, $(this).text()]
]);
});
对于.label4.lightblue4
和.label2.lightblue2
也是如此
这是一个DEMO
希望这有帮助。
关于javascript - OnClick 事件不适用于超过 10 个条目的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29083414/