2017-02-23 9 views
6

から「OK」ボタンを削除し、私はjavascriptの甘い警告ライブラリを使用しています:は甘い警告ダイアログ

https://limonte.github.io/sweetalert2/

https://github.com/limonte/sweetalert2

私は警告ボックスから[OK]ボタンを削除したいが、私は見つけることができませんでしたこのボタンを表示しないプロパティ。

私はタイマーのプロパティtimer:1000を使用してアラートを1秒で閉じます。 この問題ではOKボタンを使用しているとは思われません。

enter image description here

+0

セット 'showConfirmButton:ご使用の構成でfalse'を。 [ドキュメントへのリンク](https://limonte.github.io/sweetalert2/#allow-enter-key) – haxxxton

答えて

13

あなたはこれらのプロパティを使用することができます:あなたは、あなたの設定でshowConfirmButton:falseを設定する必要があります。この

swal({ 
    title: 'Auto close alert!', 
    text: 'I will close in 2 seconds.', 
    timer: 2000, 
    showCancelButton: false, 
    showConfirmButton: false 
}).then(
    function() {}, 
    // handling the promise rejection 
    function (dismiss) { 
    if (dismiss === 'timer') { 
     //console.log('I was closed by the timer') 
    } 
    } 
) 
+1

私のアプリで働いた:angular2 + sweetalert2、私の時間を保存しました! :) – amey

0

falseにshowConfirmButtonプロパティを設定してみてください。

Look at their docs

3

同様

showCancelButton: false, // There won't be any cancel button 
showConfirmButton: false // There won't be any confirm button 

を。

swal({ 
    title: 'Are you sure?', 
    text: "You won't be able to revert this!", 
    type: 'warning', 
    showConfirmButton:false, 
    confirmButtonText: 'Yes, delete it!' 
}) 

ここで(アラート名を仮定すると、「A」である)、その後、すべてのボタンと再度追加彼らのような明確な、任意のボタンを追加する前にfiddle

0

だ -

A.getButtonTypes().clear(); 
ButtonType OpenStorage=new ButtonType("Open Storage"); 
A.getButtonTypes().addAll(OpenStorage,ButtonType.CANCEL,ButtonType.NEXT); 

はそれを願っています助けて!

1

は、これが私の作品:$(".confirm").attr('disabled', 'disabled');

My機能:

function DeleteConfirm(c){ 
    swal({ 
      title: "Want to delete this item?", 
      text: "You will not be able to undo this action!", 
      type: "warning", 
      showCancelButton: true, 
      confirmButtonColor: "#DD6B55", 
      confirmButtonText: "Yes, delete it!", 
      closeOnConfirm: false 
     }, function(){ 
      $(".confirm").attr('disabled', 'disabled'); 

     }); 
} 
関連する問題