2016-09-02 3 views
0

製品が削除された後に表示する甘い警告があります。しかし、このページは、数秒のうちにwindow.location.reload();でリロードされます。 okをクリックしない限り、どうやってリロードできないのですか?通常のalert()のように。sweetalertでページをリロードするのを防ぐ

swal({ 
    title: "Product removed from your watchlist!", 
    type: "success", 
    confirmButtonClass: "btn-success", 
    confirmButtonText: "OK!", 
    closeOnConfirm: false 
});  
window.location.reload(); 

答えて

2
swal({ 
title: "Product removed from your watchlist!", 
type: "success", 
confirmButtonClass: "btn-success", 
confirmButtonText: "OK!", 
closeOnConfirm: false 
}, function(isConfirm){ 
    if (isConfirm) {  
     window.location.reload(); 
    } 
});  

彼らは彼らのデモでその一例を与えている:http://t4t5.github.io/sweetalert/ は言うものを確認してください - 「...とキャンセルのためのパラメータを渡すことによって、あなたは何かを実行することができます」。

関連する問題