bootbox确认无法正常工作 [英] bootbox confirm not working properly

查看:117
本文介绍了bootbox确认无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的情况下,当我点击按钮确认框被调用但同时服务器端代码执行时没有确认。我的代码是



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

 <script src="assets/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
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" />

推荐答案

试试这个





try this


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; }
         });
    }
return false;
}


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(){
(function () {


这篇关于bootbox确认无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆