2016-08-21 8 views
1

私はsweetalertを使用して削除確認を表示していますが、ロードアクションで表示中に処理しますが、動作していませんが、コードは動作しません(ロードを表示するはずです)アニメーションは、実際にはそうしていない)任意の考え?SweetAlert showLoaderOnConfirmが表示されない

このJavaScript

document.querySelector('div.test').onclick = function() { 
swal({ 
title: 'Ajax request example', 
text: 'Submit to run ajax request', 
type: 'info', 
showCancelButton: true, 
closeOnConfirm: false, 
showLoaderOnConfirm: true, 
}, function(){ 
setTimeout(function() { 
    swal('Ajax request finished!'); 
}, 2000); 
}); 
}; 

がHTML

<div class="test"> 
<button>show alert</button> 
</div> 

これはSweetalertはもうサポートされていないfiddle

答えて

3

私はあなたのファイルは(例えば旧)間違っているなどが想定しています。

スニペット:

$(function() { 
 
    $('div.test').on('click', function (e) { 
 
    swal({ 
 
     title: "Ajax request example", 
 
     text: "Submit to run ajax request", 
 
     type: "info", 
 
     showCancelButton: true, 
 
     closeOnConfirm: false, 
 
     showLoaderOnConfirm: true, 
 
    }, function() { 
 
     setTimeout(function() { 
 
     swal("Ajax request finished!"); 
 
     }, 2000); 
 
    }); 
 
    }) 
 
});
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> 
 
<link href="https://rawgit.com/t4t5/sweetalert/master/dist/sweetalert.css" rel="stylesheet"> 
 
<script src="https://rawgit.com/t4t5/sweetalert/master/dist/sweetalert.min.js"></script> 
 

 
<div class="test"> 
 
    <button>show alert</button> 
 
</div>

+0

ありがとう、あなたは、私はトリックを知らなかったこのでした私のそれはほとんどうまく働いているので、間違っていたことと、しかしところで(ヒントをありがとうございましたそのjqueryが私のデータテーブルと競合したので、私は単にそれを使用しなかった、私の1.12.3 jQueryを使用しています) – LaravelOnly

1

です。おそらく、あなたはsweetalert2に切り替えたいことがあります。

swal({ 
    title: 'Ajax request example', 
    text: 'Submit to run ajax request', 
    type: 'info', 
    showCancelButton: true, 
    showLoaderOnConfirm: true, 
    preConfirm: function() { 
    return new Promise(function(resolve, reject) { 
     // here should be AJAX request 
     setTimeout(function() { 
     resolve(); 
     }, 2000); 
    }); 
    }, 
}).then(function() { 
    swal('Ajax request finished!'); 
}).done(); 

[JSFIDDLE]

関連する問題