0

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?

1 Answer 1

1

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()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.