我有以下代码,用于使用jquery打开通用对话框。从普通的HTML表单打开时,它完美地工作(说A)。但是,当我尝试使用下面的相同代码时,当我打开A作为对话框时, 引发错误:在初始化之前无法在对话框上调用方法;尝试将方法称为“打开” 并且表格的输入被禁用。 注意:如果我单击多次打开第二个对话框的按钮,该对话框将打开,但控件保持禁用状态。
function initDialog(closeEvent) {
$("#multiSelectDialog").dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 500
},
hide: {
effect: "explode",
duration: 500
}, beforeClose: function (e, ui) {
// If the 'X' was clicked, then do not apply the "close" callback function
if (e.originalEvent && e.originalEvent.originalEvent && e.originalEvent.originalEvent.type == "click") {
$("#multiSelectDialog").dialog('option', 'close', null)
}
// Reset the properties
MultiSelectDialog_resetProperties();
},
close: closeEvent
});
}
function MultiSelectDialog_resetProperties()
{
MultiSelectDialog_Properties.AllowMultiCheck = "false";
}
/* Init the dialog and write the data to it.
Register the following events:
-Close
***Parameters***
s: The JSON used to fill the dialog.
*/
function openMultiSelectDialog(s , idProp, nameProp, closeEvent)
{
// Clear the previuos data
$("#MultiSelectDialog_List").empty();
MultiSelectDialog_DS = [];
MultiSelectDialog_SelectedItems = [];
// Parse the json data to checkbox
MultiSelectDialog_DS = JSON.parse(s);
// Hold the original list
$("#MultiSelectDialog_List").attr("data-value", s);
$("#MultiSelectDialog_List").attr("data-object", MultiSelectDialog_DS);
$("#MultiSelectDialog_List").attr("data-idProp", idProp);
$("#MultiSelectDialog_List").attr("data-nameProp", nameProp);
initDialog(closeEvent);
for (var i = 0; i < MultiSelectDialog_DS.length; i++) {
$("#MultiSelectDialog_List").append("<input type='checkbox' onchange='MultiSelectDialog_Checkbox_Changed(this)' id ='"+MultiSelectDialog_DS[i][idProp] +"' value='"
+ MultiSelectDialog_DS[i][idProp] + "' data-value='" + MultiSelectDialog_DS[i][nameProp].toLowerCase() +
"' data-object='" + MultiSelectDialog_DS[i] + "'>" +
"<label data-value ='" + MultiSelectDialog_DS[i][nameProp].toLowerCase() + "' id ='lbl" + MultiSelectDialog_DS[i][idProp] + "'>" + MultiSelectDialog_DS[i][nameProp] +
"</label> <br/>");
}
$("#multiSelectDialog").dialog("open");
}