I am using JQuery DataTables inside a modal. From that table i have a column in which it contains checkboxes. The first attempt in getting values of the checked checkboxes is all ok. However, when i close the modal and choose again, the checkbox click event is firing twice. Here is my code:
//handle event for checkbox checking.
arresting_officers_table.on("change", ":checkbox", function() {
if($(this).is(':checked')){
console.log('Adding!'); //this log fires twice when clicking only 1 checkbox
//alert('checked! ' + $(this).attr('data-value'));
arresting_officers_ids.push($(this).attr('data-value'));
arresting_officers_names.push($(this).attr('data-name'));
}else{
//remove item
var idx = arresting_officers_ids.indexOf($(this).attr('data-value'));
arresting_officers_ids.splice(idx, 1);
arresting_officers_names.splice(idx, 1);
}
});
Your response will be greatly appreciated. Thanks!
Aucun commentaire:
Enregistrer un commentaire