Reputation: 67
I have to show number of users in table in a table with pagination
And I have delete option for each user
Im using datatable pagination
It has to ask confirm before delete the user, So im using jquery .confirm
function (jquer.confirm.js)
This jquery confirm box not working in second page of pagination.
Here is my code:
$(".del_user").each(function(){
var user_id = this.id;
$("#"+user_id).confirm({
text: "Are you sure you want to delete this user?",
title: "Confirmation required",
confirm: function(button) {
<!---delete function()---->
return false;
},
cancel: function(button) {
// nothing to do
},
confirmButton: "Yes",
cancelButton: "No",
post: true,
confirmButtonClass: "btn-danger",
cancelButtonClass: "btn-default"
});
});
How to solve this?
Upvotes: 1
Views: 588
Reputation: 939
You can do this...
add "fnDrawCallback" option in your datatable function:
$('#datable_id').dataTable({
"fnDrawCallback": function () {
createconfirmationbox();
},
});
And your jquery confirmation function look like this :
function createconfirmationbox(){
$('.someclass').confirmation({
onConfirm: function () {
*do something on confirmation*
}
});}
Upvotes: 0
Reputation: 5444
Try this...
your jquery dom not loading for another tab so my experience is doing following like that
".paginate_button" is your tab button class name
$(".paginate_button").click(function(){
$(".del_user").each(function(){
var user_id = this.id;
$("#"+user_id).confirm({
text: "Are you sure you want to delete this user?",
title: "Confirmation required",
confirm: function(button) {
<!---delete function()---->
return false;
},
cancel: function(button) {
// nothing to do
},
confirmButton: "Yes",
cancelButton: "No",
post: true,
confirmButtonClass: "btn-danger",
cancelButtonClass: "btn-default"
});
});
});
Upvotes: 0