Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Javascript button event not working after page 1

Essentially I have some datatable like this: Now for some reason when I go to the second page, none of the buttons I have are working. Like when I click them nothing happens! But on the first page they work perfectly! Not sure how to fix this issue! [enter image description here][1]

//creation method of the table

var volunteerTable = $('#volunteerTable').DataTable({
     paging: true,
     pagingType: 'simple_numbers',
     columns: [ title:"First Name", title:"Last Name", title:"Email"



The trash can button code:
$('.buttonVDelete').click(function () {
    
//fill out the fields
//open the delete volunteer modal
//prepare data to send

}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When you use click() you are reading the elements available at the moment of loading the page.

In order to read new rendered elements, you must use on

$(document).on('click','.buttonVDelete', function () {
  // Your code
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading