簡単なことをしようとしています。 ユーザーが確認ボタンをクリックするまでポップアップを閉じたくありません(このオプションをオフにしましたが、ポップアップはまだ閉じています)。 これが私のコードです:
sweetAlert({
title: "Hello",
text: "<button type='button' class='btn btn-fb fb-share'>Share on Facebook</button>",
type: null,
confirmButtonText: "Close",
html: true,
closeOnConfirm: false, //It does close the popup when I click on close button
closeOnCancel: false,
allowOutsideClick: false
});
$(document).on( "click",".fb-share", function(e){
//here sweet alert closes when I press this button.
openFbPopup();
});
スイートアラートが閉じないようにするにはどうすればよいですか?
私もこれに問題があるようです。 allowOutsideClickをfalseに設定しても、それは却下されます。
@ moazam1特定のケースでは、optionsオブジェクトの後に追加パラメーターとしてコールバックを実行する必要があります。
sweetAlert({
title: "Hello",
text: "<button type='button' class='btn btn-fb fb-share'>Share on Facebook</button>",
type: null,
confirmButtonText: "Close",
html: true,
closeOnConfirm: false, //It does close the popup when I click on close button
closeOnCancel: false,
allowOutsideClick: false
}, function () {});
$(document).on( "click",".fb-share", function(e){
//here sweet alert closes when I press this button.
openFbPopup();
});
何もする必要はありませんが、次のような関数を使用します。
function (isConfirm) {
// ... Rest of code
}
手動で応答して他のことを行うことができます。
ハンドラーがないかのように、それ以外の場合はどのようにアラートを閉じるのかは理にかなっています。
アンカータグを使用している場合は、同じページにリダイレクトされるため、href = ""を削除するだけです。 アラートが自動的に閉じたのはそのためです
私はこれが遅いことを知っていますが、将来誰かを助けるかもしれません
@ moazam1オプションがに変更されました
swal({
closeOnClickOutside: false,
});
これはうまくいきませんでした。
@ moazam1ありがとうそれは私のために働いた
@ moazam1
$(document).on( "click"、 "。fb-share"、function(e){
ここで、e.preventDefault();を追加する必要があります。
openFbPopup();
それは私のために働いた。
});
最も参考になるコメント
私はこれが遅いことを知っていますが、将来誰かを助けるかもしれません
@ moazam1オプションがに変更されました
https://sweetalert.js.org/docs/#closeonclickoutside