我有一个包含行的表,可以通过单击每行旁边的图标来删除这些行。单击该图标时,会出现一个确认对话框,要求用户确认。
无论采取哪种操作(是、否、X)都会导致“太多递归”错误。该函数有效,因为行被删除,对话框关闭,但它会导致 TMR 错误并耗尽 Firefox 内存。
$('a img.delete').live('click', function(event){
rowid = this.name;$('#' + rowid).addClass('ui-state-highlight');
$("#dialog-del-r").dialog('open');
return false;
});
$("#dialog-del-r").dialog({autoOpen:false,height:225,width:250,modal:false,position:[700,150],
buttons: {'Yes': function() {
$('#summary-report').empty();
$('#' + rowid).remove();
$(this).dialog('close');
},
'No': function() {
$('#' + rowid).removeClass('ui-state-highlight');
$(this).dialog('close');
}}
,close: function() {
$('#' + rowid).removeClass('ui-state-highlight');
$(this).dialog('close');
}
});
任何这些行 $(this).dialog('close');导致问题发生。
我还有一个表单重置按钮,它的作用完全相同:
$('#reset-form').button({icons: {primary:'ui-icon-trash'}}).click(function(){
$('#dialog-reset').dialog('open');
});
$("#dialog-reset").dialog({autoOpen:false,height:225,width:250,modal:false,position:[200,350],buttons: {'Yes': function() {$(this).dialog('close');location.reload(true);},'No': function() {$(this).dialog('close');}},close: function() {$(this).dialog('close');}});
最佳答案
我设法解决了这个问题。 close, 部分会自动关闭对话框,而我在那里有对话框('close')。
,close: function() {
$('#' + rowid).removeClass('ui-state-highlight');
$(this).dialog('close');
}
应该是:
,close: function() {
$('#' + rowid).removeClass('ui-state-highlight');
}
关于jquery - 关闭对话框导致太多递归,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3153547/