问题描述
我有一个jQuery的应用程序1.5,对话框工作正常。虽然我有很多的.live处理程序,我把它改成了.on。
为此,我必须更新jquery(现在是1.8.3一个jquerui 1.9.1)。
现在,我得到:错误:初始化前无法调用对话框中的方法;尝试调用方法'close'
以下是代码:
Javascript
var opt = {
autoOpen:false,
modal:true,
width: 550,
height:650,
title:'Details'
};
$(document).ready(function(){
$(#divDialog)。对话框(opt);
$(#divDialog)对话框open);
...
html代码
< div id =divDialog>
< div id =divInDialog>< / div>
< / div>
任何想法可能会发生什么?
尝试这样做
$(document) (function(){
$(#divDialog)。对话框(opt).dialog(open);
});
您还可以:
var theDialog = $( #divDialog)对话框(opt);
theDialog.dialog(open);
这是因为对话框不存储在 $('#divDialog')
中,而是在一个新的div上,由fly创建并由$ code> .dialog(opt)函数。
I have an app on jquery 1.5 with dialogs worked fine.While I have a lot of .live handlers, I changed this to .on.For that, I have to update jquery (now 1.8.3 an jquerui 1.9.1).
Now, I got: Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'
Following is the code:
Javascript
var opt = {
autoOpen: false,
modal: true,
width: 550,
height:650,
title: 'Details'
};
$(document).ready(function() {
$("#divDialog").dialog(opt);
$("#divDialog").dialog("open");
...
html code
<div id="divDialog">
<div id="divInDialog"></div>
</div>
Any idea why this might be happening?
Try this instead
$(document).ready(function() {
$("#divDialog").dialog(opt).dialog("open");
});
You can also do:
var theDialog = $("#divDialog").dialog(opt);
theDialog.dialog("open");
That's because the dialog is not stored in $('#divDialog')
, but on a new div that is created on the fly and returned by the .dialog(opt)
function.
这篇关于jquery ui Dialog:在初始化之前无法调用对话框中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!