Jquery确认对话在Content Place持有人中不起作用

时间:2017-07-31 09:25:32

标签: javascript jquery asp.net

我试图使用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>
&#13;
&#13;
&#13;

请注意,这适用于常规网络表单或页面。所以所有导入的链接都没问题。但每当我放入母版页中包含的页面时,它都没有。

2 个答案:

答案 0 :(得分:0)

在包含jquery.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>
vagrant ssh -- -t 'tail -f PATH_TO_LOG/production.log'

答案 1 :(得分:0)

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

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

尝试这种方式。