Before bootbox, I did this on aspx file in gridview;
<asp:Button ID="btnDelete" CssClass="btn btn-danger" OnClientClick="if(!confirmDelete()) return false;" runat="server" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" CausesValidation="false" CommandName="DeleteRow" Text="Delete"/>
and on js file;
function confirmDelete() {
return confirm("Are you sure you want to delete the record?"); }
And with confirmation, the gridview's RowCommand is triggered and the deletion is done.
With bootbox, I am realy stuck. I know bootbox is asynchronus and try to use 'preventDefault', but it didn't work. So how can I convert the above js file to bootbox version? Thanks in advance.
I finally come up with this solution;
function confirmDelete(sender) {
if ($(sender).attr("confirmed") == "true") {return true;}
bootbox.confirm("Are you sure you want to delete?", function (confirmed) {
if (confirmed) {
$(sender).attr("confirmed", confirmed).trigger("click");
}
});
return false;
}
And changing button's OnClientClick;
OnClientClick="return confirmDelete(this);"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With