【问题标题】:bootbox confirm dialog box, cancel button is not workingbootbox 确认对话框,取消按钮不起作用
【发布时间】:2020-03-02 15:24:47
【问题描述】:

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

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】:

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

    callback: function (result) {
    
    }
    

    如果用户通过单击“取消”或关闭 (x) 按钮取消对话框,则 result(或任何您调用的参数)将是值 false。您可以像这样使用该值:

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

    in the documentation 或多或少地涵盖了这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-19
      • 1970-01-01
      • 2017-10-09
      • 2011-09-16
      • 2020-08-17
      • 1970-01-01
      相关资源
      最近更新 更多