JS错误:jquery-1.4.4.js中的递归过多

时间:2011-03-22 10:06:18

标签: jquery jquery-ui

我正在使用jQuery打开一个对话框。当我尝试关闭对话框时,会抛出js error

"Error: too much recursion Source File:
     

http://localhost:8080/testProject/scripts/jquery-1.4.4.js   行:648“

对话的功能如下:

jQuery(function() {

        jQuery( "#purchaseOrderDevice-form" ).dialog({
            bgiframe:true,
            autoOpen: false,
            height: 550,
            width: 870,
            modal: true,
            resizable : true,

            close: function() {
                jQuery( "#purchaseOrderDevice-form" ).dialog( "close" );
            }

        });

        jQuery( "#purchaseOrderDevice" ).button().click(function() {
                jQuery( "#purchaseOrderDevice-form" ).dialog( "open" );
        });
    });

2 个答案:

答案 0 :(得分:3)

jQuery( "#purchaseOrderDevice-form" ).dialog({
            bgiframe:true,
            autoOpen: false,
            height: 550,
            width: 870,
            modal: true,
            resizable : true,

            close: function() {
            },
            buttons: {
               'Close': function () {
                  $(this).dialog("close");
                }
            }

        });

这是应该怎么做的 - 不要告诉它每次关闭时关闭,否则你得到一个循环。

答案 1 :(得分:0)

你应该删除这段代码

jQuery( "#purchaseOrderDevice-form" ).dialog( "close" );

因为当您致电close: function() {}该对话框已关闭时,所以当您再次尝试关闭该对话框时,会导致该错误

希望这有帮助