bootbox确认对话框,取消按钮不起作用

问题描述 投票:0回答:1

我有一个启动箱确认对话框。在那,我有一些表单验证。验证工作正常,只要验证失败,确认对话框仍会打开。但是当我单击“取消”按钮时,它仍在要求验证。

bootbox.confirm({ 
    closeButton: true,
    message: valid_result,
    size: 'large',
    title: 'Fill fields with related values',
     buttons    : {
     confirm : { label: '<i class="fa fa-check"></i> Validate'}
    }, 

      callback: function () {                  
           var res =  getLinkupInformation(ids_string)
            if(res == true) {
              return true;
            } else {
              return false;
            }

      }
  });

验证部分正在运行,如果通过验证,则仅模式关闭。但是当用户单击“取消”按钮或关闭图标时,它仍在询问验证。 When I remove return false in call back function in else part,然后是validation button is not working,当是I click on the validate button confirmation dialog box was closing时。请指导我如何解决此问题?

bootbox
1个回答
0
投票

回调希望您提供一个参数,如下所示:

callback: function (result) {

}

如果用户通过单击取消或关闭(x)按钮取消了对话框,则result(或您所称的自变量)将为值false。您可以这样使用该值:

callback: function (result) {
    if(result) {
        /* your code here */
    }
}

或多或少覆盖了in the documentation

© www.soinside.com 2019 - 2024. All rights reserved.