Jquery 对话框 - 对象不支持此属性或方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5181449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jquery Dialog - Object doesn't support this property or Method
提问by user643062
My this code was working fine until I upgraded to Jquery newer version. Now I get above error.
我的这段代码运行良好,直到我升级到 Jquery 更新版本。现在我得到了上述错误。
<link rel="stylesheet" type="text/css" href="site.css" />
<link type="text/css" href="css/smoothness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.10.custom.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#dialog').dialog({
modal: true,
autoOpen: false,
width: 760,
height: 'auto',
close: function(event, data) {
$('#mainFrame')[0].src = "LoadingPage.aspx";
}
});
$('a[name="dia"]').click(function(){
$('#mainFrame')[0].src = this.file;
$('#dialog').data('title.dialog', this.innerText);
// $('#dialog').data('width.dialog', this.diaWidth);
// $('#dialog').data('height.dialog', this.diaHeight);
$('#dialog').dialog('open');
return false;
});
if (document.getElementById('hidIsAdmin').value == "1"){
document.getElementById('liAdmin').style.display = 'block';
document.getElementById('liReports').style.display = 'block';
}else {
$('#liAdmin').remove();
$('#liReports').remove();
}
if (document.getElementById('hidCreate').value == "1"){
document.getElementById('liCreate').style.display = 'block';
}else {
$('#liCreate').remove();
$('.edit_icon_link').hide(0);
}
});
function hideEditIcon(){
$('.edit_icon_link').hide(0);
}
</script>
回答by James in Indy
I had something similar happen (converting MVC3 ASP to Razor), and in my case, moving my jquery-1.4.4.min.js
reference to my master page helped.
我发生了类似的事情(将 MVC3 ASP 转换为 Razor),就我而言,将我的jquery-1.4.4.min.js
参考移动到我的母版页有帮助。
I say "helped"because now the open works, but the $(this).dialog("close");
doesn't.
我说“帮助”是因为现在开放的作品,但 $(this).dialog("close");
没有。
function ShowPopUp(strDivName)
{
$("div[id$='" + strDivName + "']").dialog(
{
title: "blah blah blah",
width: 600,
modal: true,
resizable: true,
closeOnEscape: false,
buttons:
{
"Save": function () { SaveThis(); $(this).dialog("close"); },
"Cancel": function () { $(this).dialog("close"); }
}
}
);
$("div[id$='" + strDivName + "']").dialog("open");
}
回答by Christopher Johnson
I ran into this problem with IE8 because I was on a HTTPS page but loading jquery-ui package from a HTTP CDN. As soon as I changed the url from
我在使用 IE8 时遇到了这个问题,因为我在 HTTPS 页面上但从 HTTP CDN 加载 jquery-ui 包。一旦我改变了网址
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
to
到
https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
it started working.
它开始工作。
回答by Boydski
I'm now using MVC4. So I had to add jquery-ui-1.8.20.jsto the BundleConfig.RegisterBundles()
under App_Start to get it to work:
我现在正在使用 MVC4。所以我不得不将jquery-ui-1.8.20.js添加到BundleConfig.RegisterBundles()
App_Start 下才能让它工作:
bundles.Add( new ScriptBundle( "~/bundles/jquery" ).Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-1.8.20.js" ) );
回答by DGM
Check the options available for dialog, I think autoResize has been renamed to resizable.
检查对话框可用的选项,我认为 autoResize 已重命名为可调整大小。
回答by Mike C
Is it possible that you are not closing your $(document).ready(function(){
?
有没有可能你没有关闭你的$(document).ready(function(){
?
The });
you are showing above closes the $('#dialog').dialog({
but I don't see a close of the $(document).ready(function(){
.
在});
你上面显示关闭$('#dialog').dialog({
,但我没有看到的亲密$(document).ready(function(){
。