2017-07-31 5 views
0

JQUERY Confirmダイアログを使用して、ユーザーに[OK]または[キャンセル]を押すように要求しています。私はmasterpageの中にあるページを入れるまでうまくいきます。確認アラートは1ミリ秒間表示され、消えます。コンテンツプレースホルダでJqueryの確認ダイアログが機能しない

window.onload = function() { 
 
    $("#ehi").click(function() { 
 
    $.confirm({ 
 
     title: 'Are you sure you want to approve this application? Note: This action cannot be reverted. An automatic email will be sent to the student to notify him/her of the decision.', 
 
     content: '', 
 
     buttons: { 
 
     confirm: function() { 
 
      $.confirm({ 
 
      title: 'Confirmed confirmation!', 
 
      content: 'Simple confirmation!', 
 
      buttons: { 
 
       confirm: function() { 
 

 
       }, 
 
       cancel: function() { 
 

 
       }, 
 

 
      } 
 
      }); 
 
     }, 
 
     cancel: function() { 
 

 
     }, 
 
     somethingElse: { 
 
      text: 'Something else', 
 
      btnClass: 'btn-blue', 
 
      keys: ['enter', 'shift'], 
 
      action: function() { 
 
      $.alert('Something else?'); 
 
      } 
 
     } 
 
     } 
 
    }); 
 
    }); 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.3/jquery-confirm.min.css"> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.3/jquery-confirm.min.js"></script> 
 

 

 
<button id="ehi" class="btn btn-info">confirm</button>

これは、通常のWebフォームまたはページで正常に動作しますのでご注意ください。したがって、インポートされたリンクはすべて正常です。しかし、私がマスターページに含まれているページの中に置くたびに、それはしません。

答えて

0

jquery.min.jsの後にjquery-confirm.min.jsファイルを含める必要があります。これらのスクリプトはすべて、コードを実行する前にロードする必要があります。

window.onload = function() { 
 
    $("#ehi").click(function() { 
 
    $.confirm({ 
 
     title: 'Are you sure you want to approve this application? Note: This action cannot be reverted. An automatic email will be sent to the student to notify him/her of the decision.', 
 
     content: '', 
 
     buttons: { 
 
     confirm: function() { 
 
      $.confirm({ 
 
      title: 'Confirmed confirmation!', 
 
      content: 'Simple confirmation!', 
 
      buttons: { 
 
       confirm: function() { 
 

 
       }, 
 
       cancel: function() { 
 

 
       }, 
 

 
      } 
 
      }); 
 
     }, 
 
     cancel: function() { 
 

 
     }, 
 
     somethingElse: { 
 
      text: 'Something else', 
 
      btnClass: 'btn-blue', 
 
      keys: ['enter', 'shift'], 
 
      action: function() { 
 
      $.alert('Something else?'); 
 
      } 
 
     } 
 
     } 
 
    }); 
 
    }); 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.3/jquery-confirm.min.js"></script> 
 
<button id="ehi" class="btn btn-info">confirm</button>

0
<button id="ehi" type="button" class="btn btn-info">confirm</button> 

OR

$("#ContentPlaceHolder1_ehi").click(); 

この方法を試してみてください。

+0

いいえ、私はそれが問題ではないかと恐れています。確認ダイアログは表示されていますが、ミリ秒単位で消えています。私はmasterpageが何らかのリフレッシュページを引き起こしていると思います –