click checkbox after filter

click checkbox after filter

HokwangHokwang Posts: 8Questions: 4Answers: 0
edited October 2013 in DataTables 1.9
Hello.

It looks like a bug.

You can test below code.

Type "b_" in filter.
And then click the checkbox in row2 (b_2 line).
You will see alert popup 3 times. <- I think it is bug.

Thank you.

[code]

<!doctype html>















$(document).ready(function() {
$("table").dataTable({
"bAutoWidth": false,
"bJQueryUI": true,
"bSortClasses": false,
"iDisplayLength": 25,
"sPaginationType": "full_numbers",
"fnDrawCallback": function() {
$("input[type='checkbox']").click(function() {
alert($(this).parent("td").prev().text());
});
}
});
});






V
check




a_1



a_2



b_1



b_2






[/code]

Replies

  • MisiuMisiu Posts: 68Questions: 4Answers: 2
    It's not a bug, first time table is rendered click event is attached to every checkbox, second time You click the same event is attached again.

    Solution is easy: declare event listener outside Your table. See http://jsfiddle.net/Misiu/TtvKW/

    [code]
    $(document).on('click', "input[type='checkbox']", function () {
    alert($(this).parent("td").prev().text());
    });
    [/code]

    I didn't check that code, but is should work just fine :)
This discussion has been closed.