我知道这个主题有很多线程。搜索了很多已经好几天了(!)......因此而变得疯狂。 我检查了这些: Uncaught TypeError: Object #<Object> has no method 'dialog' Uncaught TypeError: Object [object Object] has no method 'dialog'Uncaught TypeError:Object [object Object] has no method'dialog'
不能明白我做错了,需要你的帮助。下面是我正在努力工作的代码。
Index.chtml
@{
ViewBag.Title = "Home Page";
}
<br/>
<input type="button" value="Get Form" onclick="getForm()" />
<script type="text/javascript">
function getForm(){$('#dialog').dialog({
autoOpen: true,
width: 400,
resizable: false,
title: 'My Table',
modal: true,
open: function(event, ui) {
$(this).load('@Url.Action("Index", "Home")');
},
buttons: {
"Close": function() {
$(this).dialog("close");
}
}
});
}</script>
<div id="dialog"></div>
控制器
public ActionResult _dialog()
{
return View();
}
public ActionResult Index()
{
return View();
}
_dialog.chtml
<h3>Partial View code</h3>
_Layout.chtml
...
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="~/Scripts/jquery-ui-1.10.4.min.js"></script>
<link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
...
你错过了jQuery UI库的链接吗? –
检查您的外部脚本是否已正确嵌入到呈现的HTML代码中,并且可以实际到达(不是404或类似的东西)。 – CBroe
^是的,将链接(src)复制到jquery ui lib并粘贴到您的浏览器(带域名),你能看到它吗? –