Reputation: 11
In my case when I click on button confirm-box is called but at the same time server side code executes without confirmation. My code is
function btnApprovePayments()
{
var ans = checkrecordofpayment(); //here returns true or false
if (ans == true) {
bootbox.confirm("Are You Sure To Approve This Payment ?", function (e) {
if(e)
{ return true; }
});
}
}
<asp:Button ID="btn_Approve_Payments" runat="server" Text="Approve" OnClientClick="return btnApprovePayments();" onclick="btn_Approve_Payments_Click" />
Upvotes: 0
Views: 2702
Reputation: 79
bootbox.confirm is asynchronus in behaviour so we can't stop its flow. we have to change our behaviour of the problem
first of all you have to prevent the default behaviour of bootbox by applying e.preventdefault(); then add your logic in true section whatever you want to do . then call server side function by using __doPostBack('btnDelete', 'OnClick');
$(function () {
$(".popup_button_delete").click(function (e) {
e.preventDefault();
var counter = GetSelected();
if (counter > 0) {
bootbox.confirm(' <%=GetLocalResourceObject("DeleteConfirm") %> ', function (confirmed) {
if (confirmed == true) {
__doPostBack('btnDelete', 'OnClick');
}
});
}
else {
bootbox.alert('<%=GetLocalResourceObject("NoSelectionAlert")%>');
}
});
});
Upvotes: 1