Preconditions (*)
- You are using Datatables & And for the Click event you are using jQuery & you are using pagination
Steps to reproduce (*)
- Use a Datatables and on Action button you just use the class or id to make a click event to get row data on second or other pagination
Expected result (*)
- The click should work for the edit event
Actual result (*)
- The click trigger not working
Problem :
jQuery('.editVendorAction').on('click', function (e) { let id = ($(this).attr("data-id")); getSingleVendor(id); });
Solution :
we need to use event-delegation approach
jQuery('#dtVendor').on('click', '.editVendorAction', function (e) { let id = ($(this).attr("data-id")); getSingleVendor(id); });
We use parent id in jQuery main selector
Leave A Comment?
You must be logged in to post a comment.