2016-05-24 102 views
2

我在我的项目中使用ngSweetAlert当点击取消按钮时ngSweetAlert垂直滚动条消失

除了当我添加showCancelButton: true属性时,它完美的工作。

事实上,例如:

SweetAlert.swal({ 
    title: "Are you sure?", 
    text: "Your will not be able to recover this imaginary file!", 
    type: "warning", 
    showCancelButton: true, 
    confirmButtonColor: "#DD6B55", 
    confirmButtonText: "Yes, delete it!", 
    closeOnConfirm: false}, 
function(){ 
    //do something if "Yes, delete it!" button is clicked 
}); 

当它叫,甜警报窗口出现,在这一刻,垂直滚动条被禁用,没问题到现在为止。

用户有两个选择,在这种情况下:“是的,删除”

  • 点击按钮:甜蜜的警报消失,我的垂直滚动条返回。
  • 点击按钮“取消”: 如此甜蜜警报消失,但我的问题是的事实,我的垂直滚动条仍然是禁用,这不应该是这样的!

一个可行的办法是我<body> HTML标记添加overflow-y: auto; CSS属性,但问题是,在显示甜警报垂直滚动条不禁止。 (这不是理想的我想要的...)

以前有人有过这个问题吗?

回答

1

我解决我的问题,你只需要添加:

closeOnCancel: true 

所以现在,它看起来像这样:

SweetAlert.swal({ 
    title: "Are you sure?", 
    text: "Your will not be able to recover this imaginary file!", 
    type: "warning", 
    showCancelButton: true, 
    confirmButtonColor: "#DD6B55", 
    confirmButtonText: "Yes, delete it!", 
    closeOnConfirm: false, 
    closeOnCancel: true}, 
function(){ 
    //do something if "Yes, delete it!" button is clicked 
});