2016-05-24 157 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 
});