It is because there are multiple click event handlers registered when the second delete button is clicked.
Remove the previous handler using off()
as one solution
$('body').on('click', '.delete_item', function (e) {
e.preventDefault();
var url = $(this).data('url');
var data = 'item_id=' + $(this).data('item_id');
var btn = $(this);
$(btn).parents('form').children('.modal').modal('show');
$('.modal-body').off('click.confirm').on('click.confirm', '.confirm_delete', function (e) {
e.preventDefault();
var confirm = $(this);
$.ajax({
type: 'post',
url: url,
data: data,
dataType: 'json',
cache: false,
success: function (data) {
if (data.status) {
$(btn).parent('.btn').remove();
} else {
alert('error');
}
},
complete: function () {
$(confirm).parents('.modal').modal('hide');
}
});
});
});