<script src="path/to/jquery.js"></script>
<script src="path/to/bootstrap.js"></script>
<script src="path/to/bootstrap-confirmation.js"></script>
I use Bootstrap Confirmation.
This doesnt work :
<a class="btn btn-danger btn-xs" data-toggle="confirmation"
onclick="DeleteUser(this);" data-id="10"><span class="fa fa-plus">
</span> Delete</a>
This works same page :
<button class="btn btn-default" data-
toggle="confirmation">Confirmation</button>
<a class="btn btn-default" data-toggle="confirmation">Confirmation1</a>
My confirmation settings on document ready
$('[data-toggle="popover"]').popover({ placement: 'left', html: true, trigger: 'hover' });
$('[data-toggle=confirmation]').confirmation({ btnOkLabel: 'Yes', btnCancelLabel: 'No', title: 'Are you sure?' });
UPDATE My ajax delete function :
function DeleteUser(ele) {
var id = $(ele).attr('data-id');
$.ajax({
type: 'POST',
cache: false,
url: '../ashx/FriendOperation.ashx',
data: { id: id, rol: ' ' ,op:<%=(int)CrudOp.Delete%>},
beforeSend: function () {
//bla bla
},
success: function (data) {
var jsonData = JSON.parse(data);
if (jsonData != null) {
if (parseInt(jsonData) > 0) {
alert('okey');
GetFriendOp();
} else {
alert('expception');
}
} else {
alert('expception');
}
}
});
}
Can I combine with AJAX like $('#element').confirmation('show');
SUCCESS :
$("[data-toggle=confirmation]").confirmation({btnOkLabel: 'Yes', btnCancelLabel: 'No', title: 'Are you sure?',container:"body",btnOkClass:"btn btn-sm btn-success btn-xs",btnCancelClass:"btn btn-sm btn-danger btn-xs",onConfirm:function(event, element) { alert('confirm clicked'); }});
Thanks @DanCouper .