未捕获的类型错误:对象 [对象对象] 没有方法“对话" [英] Uncaught TypeError: Object [object Object] has no method 'dialog'
问题描述
我正在尝试在 MVC3 应用程序中使用 jQueryUI 对话框,但遇到了问题.我拥有的对话框正在将部分视图加载到其中,用户将在其中编辑或创建新项目.这很好,但如果我尝试保存或更新项目,或者如果我尝试关闭它,我会在标题中看到消息.
I am trying to use the jQueryUI dialog in an MVC3 application but having an issue with it. The dialog I have is loading a partial view into it where the user will either edit or create a new item. This works fine but if I try to save or update the item, or if I try to close it I get the message in the title.
我已添加所有必需的 .js 文件,但仍然出现错误.我也使用了 firebug,但仍然找不到发生错误的原因.
I have added all of the required .js files but still getting the error. I have also used firebug but still can't find why error is happening.
HTML
<span class="EditLink ButtonLink" addressId="@addr.Id">Modify this Address</span>
<div id="popup"></div>
JavaScript
$(document).ready(function () {
var id = 0;
//define config object
var dialogOpts = {
title: "Edit item",
modal: true,
autoOpen: false,
height: 500,
width: 500,
open: function () {
$("#popup").load("/partialviewtoload/" + id);
},
buttons: {
Cancel: function() {
$(this).dialog('close');
}
}
};
$("#popup").dialog(dialogOpts); //end dialog
$('.EditLink').click(function() {
id = $(this).attr("itemId");
$("#popup").dialog("open");
return false;
});
});
推荐答案
问题是我引用了两次jquery-1.5.1.min.js".进入 _Layout.cshtml 以及我正在加载的部分视图中..删除了局部视图中的引用并对其进行了排序.
issue was that I was referencing "jquery-1.5.1.min.js" twice. Once in the _Layout.cshtml and also in the partial view I was loading. . Removed the reference in the partial view and got it sorted.
这篇关于未捕获的类型错误:对象 [对象对象] 没有方法“对话"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!