首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jquery确认对话在内容占位符中不起作用

Jquery确认对话在内容占位符中不起作用
EN

Stack Overflow用户
提问于 2017-07-31 17:25:32
回答 2查看 430关注 0票数 0

我正在尝试使用一个JQUERY确认对话框,要求用户按下ok或cancel。它工作得很好,直到我把一个页面放在一个母版页里面。确认警报会显示一毫秒,然后消失。

代码语言:javascript
复制
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?');
          }
        }
      }
    });
  });
}
代码语言:javascript
复制
<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>

请注意,这在常规的page表单或页面中工作得很好。所以所有导入的链接都是好的。但是,每当我将页面放入母版页中时,它并不是这样的。

EN

回答 2

Stack Overflow用户

发布于 2017-07-31 17:31:23

在包含jquery.min.js之后,您需要包含jquery-confirm.min.js文件。所有这些脚本都应该在执行代码之前加载。

代码语言:javascript
复制
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?');
          }
        }
      }
    });
  });
}
代码语言:javascript
复制
<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
EN

Stack Overflow用户

发布于 2017-07-31 17:39:38

代码语言:javascript
复制
 <button id="ehi" type="button" class="btn btn-info">confirm</button>

代码语言:javascript
复制
$("#ContentPlaceHolder1_ehi").click();

试试这个方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45412025

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档