繁体   English   中英

如何读取引导程序确认OK / Cancel事件?

[英]how to read bootstrap confirmation OK/Cancel event ?

我正在开发MVC应用程序。 我正在为CSS使用bootstrp。

我正在使用警报/对话来确认删除记录。 但是对于如何读取用户的“确定”或“取消”响应感到困惑。

 var href = $(this).attr('href');
        if (!$('#dataConfirmModal').length) {
            $('body').append('<div id="dataConfirmModal" class="modal" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h6 id="dataConfirmLabel">Deactivation Confirmation</h6></div><div class="modal-body">Are you sure to deactive @Model.Name ? </div><div class="modal-footer"><button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button><a class="btn btn-primary" id="dataConfirmOK">OK</a></div></div>');
        } 
        $('#dataConfirmModal').find('.modal-body').text($(this).attr('data-confirm'));
        $('#dataConfirmOK').attr('href', href);
        $('#dataConfirmModal').modal({show:true});
        return false;

您是否尝试过bootboxjs,它通过方式使用Bootstrap

我给你一个示例代码:

bootbox.confirm("Are you sure?", function(result) {
  if (result)
    {
      Example.show("You press Ok");
     }
   else
   {
      Example.show("You press Cancel");
   }
}); 

就个人而言,我在每个模式按钮上使用click事件来执行我想要的操作。

我不认为模态会发送结果,正如我们在其他语言中所看到的那样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM