Javascript 连续调用后JQuery弹出窗口不工作
我的项目使用MVC4,我试图在弹出窗口中编辑或显示我的数据 当我调用OpenPopup代码6或7次时,我会出现javascript错误 我的控制器是Javascript 连续调用后JQuery弹出窗口不工作,javascript,jquery,asp.net-mvc,asp.net-mvc-4,Javascript,Jquery,Asp.net Mvc,Asp.net Mvc 4,我的项目使用MVC4,我试图在弹出窗口中编辑或显示我的数据 当我调用OpenPopup代码6或7次时,我会出现javascript错误 我的控制器是 public ActionResult OpenEditForm(string objectParam, string formStatus) { BranchNotesDetailViewModel viewModel = new BranchNotesDetailViewModel(); //.
public ActionResult OpenEditForm(string objectParam, string formStatus)
{
BranchNotesDetailViewModel viewModel = new BranchNotesDetailViewModel();
//..................
return PartialView("Edit", viewModel);
}
我的javascript代码是
myDialog = $("<div> </div>");
function CreateDialog(name) {
myDialog.dialog({
autoOpen: false,
title: name,
resizable: false,
position: 'center',
stack: true,
height: 'auto',
width: 'auto',
modal: true,
close: function (event, ui) {
// remove div with all data and events
myDialog.remove();
//myDialog.dialog('close')
}
});
}
$('#brancNotesList .grid-row').click(function () {
var json = $(this).children('td:eq(1)').text().trim();
$.ajax({
contentType: 'application/html',
url: '@Url.Action("OpenEditForm", "BranchNotes")',
dataType: 'html',
type: 'GET',
data: {
objectParam: json,
formStatus: "1"
}
}).done(function (result) {
CreateDialog('Detail');
myDialog.html(result).dialog('open');
});
});
$(function () {
$(document).ajaxComplete(function (event, request, settings) {
//re-parse the DOM after Ajax to enable client validation for any new form fields that have it enabled
$.validator.unobtrusive.parse(document);
});
});
function openFormCreate() {
$.ajax({
contentType: 'application/html',
url: '@Url.Action("OpenEditForm", "BranchNotes")',
dataType: 'html',
type: 'GET',
data: {
formStatus: '2'
}
}).done(function (result) {
CreateDialog('Detail');
myDialog.html(result).dialog().dialog('open');
});
}
当我打开对话框一次或两次时,它会工作,但在第五次或第六次之后,它会异常崩溃
JavaScript运行时错误:由于错误80020101,无法完成操作
在ajax调用后,我试图找到内存问题或其他问题,但找不到位置或内容。有办法处理吗?我在一些论坛上读到了这个问题,他们说评论栏导致了这个问题,但它对我不起作用。我发现了我的错误。我有两个布局,一个用于主页,一个用于编辑页面,我注意到两个页面中都呈现了一些Jquery脚本文件。我从jquery脚本中清理了编辑布局,然后一切正常