Laravel Chumper Datatables Post AJAX update

Laravel Chumper Datatables Post AJAX update

kirobokirobo Posts: 1Questions: 1Answers: 0

I am trying to use Chumper datatables in my project. Now I have a column with delete row. Basically, which deletes a row if you click it. But when you click it, it, there's a connfirmation dialogue box which asks if you're sure to delete it.

Now it works if I do not use any AJAX call after first page content load and row id is posted to the controller method.

But if I sort or filter the data using the search box, the id is not extracted. That means that when new content is loaded, the id and other data of new elements is not being taking properly by the jquery method:

function confirmation() {
$('.delete').on('click', function(e) {
e.preventDefault();
var el = $(this).parent();
var data = el.attr('data-form');
console.log(data);
$('.myModal').find('.confirm').attr('data-form', data);
});
$('.myModal').on('click', '.confirm', function(e) {
var id = $(this).attr('data-form');
console.log(id);
window.location = "{{URL::route('deleted.success') .'/'}}" + id;

});

}
$(window).load(function() {
confirmation();
});
When new data is loaded and delete is clicked, instead of id (loaded in data-form) it says undefined. How to get correct ID here after AJAX call?

This discussion has been closed.