I want to display 3 tables with different data types, on 1 page, using livewire.
The problem is in the bulk delete button..
The first time the page loads, the delete button works fine, if any checkbox is selected.
But if the data in the table changes, due to changing data types or search results, the delete button does not work even if a checkbox is selected.
I am using jquery to enable bulk delete button.
This is the button:
<button id='hapusMasal' disabled>Hapus Masal</button>
This is the script
$('tr').click(function() {
var len = $(".checkbox:checked").length;
if (len == 0) {
$("#hapusMasal").prop("disabled", true);
} else {
// alert('ok');
$("#hapusMasal").removeAttr("disabled");
}
});
I check the checkbox when any of the data row is clicked, not only when I click in the checkbox input.
Can anyone tell me what should I do?
CodePudding user response:
update it to
$(document).on('click', 'tr', function() {
var len = $(".checkbox:checked").length;
if (len == 0) {
$("#hapusMasal").prop("disabled", true);
} else {
// alert('ok');
$("#hapusMasal").removeAttr("disabled");
}
});
these edits change the code from bind to live for more info please check the following article difference between on() and live() or bind()