javascript - 错误 : TypeError: $(. ..).dialog 不是函数

标签 javascript jquery jquery-ui-dialog

我在将对话框用作基本功能时遇到问题。这是我的 jQuery 源导入:

<script type="text/javascript" src="scripts/jquery-1.9.1.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-1.11.1.js"></script>
<script type="text/javascript" src="scripts/json.debug.js"></script>

HTML:

<button id="opener">open the dialog</button>
<div id="dialog1" title="Dialog Title" hidden="hidden">I'm a dialog</div>

<script type="text/javascript">
    $("#opener").click(function() {
            $("#dialog1").dialog('open');
    });
</script>

从周围的帖子来看,这似乎是一个库导入问题。我下载了 JQuery UI Core、Widget、Mouse 和 Position 依赖项。

有什么想法吗?

最佳答案

一定要插入完整版的 jQuery UI。你也应该先初始化对话框:

$(function () {
  $( "#dialog1" ).dialog({
    autoOpen: false
  });
  
  $("#opener").click(function() {
    $("#dialog1").dialog('open');
  });
});
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
 
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" />

<button id="opener">open the dialog</button>
<div id="dialog1" title="Dialog Title" hidden="hidden">I'm a dialog</div>

关于javascript - 错误 : TypeError: $(. ..).dialog 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40574173/

相关文章:

php - 如何使用bootstrap模式从mysql中删除?

jquery - 使用 ASP.NET MVC3 将表单数据从 jqueryUI 对话框传递到 Controller

javascript - BreezeJS - 删除在自定义上下文提供程序中引用的实体

javascript - 如何在 JavaScript 中递归地构建菜单列表对象?

javascript - 数据表createdRow函数未将id设置为行元素

javascript - 如何匹配单个后代(如 $.find())而不在找到 DOM 树的其余部分后进行搜索?

asp.net - 当页面显示在 jQuery 对话框和 iFrame 中时调整图像大小

jquery - 使用jqueryUI 对话框模仿confirm()

javascript - 知道一个元素是否可以在窗口调整大小时适合另一个元素

ajax - 如何使用innerHTML在AJAX中执行包含JS的页面?