Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我在jquery对话框中加载html页面,但当我关闭对话框并再次打开对话框时,会出现以下错误_Jquery - Fatal编程技术网

我在jquery对话框中加载html页面,但当我关闭对话框并再次打开对话框时,会出现以下错误

我在jquery对话框中加载html页面,但当我关闭对话框并再次打开对话框时,会出现以下错误,jquery,Jquery,我在jQuery对话框中加载html页面,但当我使用“关闭”按钮关闭对话框并再次打开对话框时,出现以下错误: Error: cannot call methods on dialogue prior to initialization; attempted to call method 'isOpen' 我的代码 $("#enterRunnerPositionDialog").dialog({ autoOpen: false, position: 'center', t

我在jQuery对话框中加载html页面,但当我使用“关闭”按钮关闭对话框并再次打开对话框时,出现以下错误:

Error: cannot call methods on dialogue prior to initialization; attempted to call method 'isOpen'
我的代码

$("#enterRunnerPositionDialog").dialog({
    autoOpen: false,
    position: 'center',
    title: 'Enter Runner Position Selection',
    draggable: false,
    width: 1000,
    height: 900,
    resizable: false,
    modal: true,
    open: function (event, ui) {
        var html = "";
        $.ajax({
            type: "GET",
            url: "AdminController",
            data: {
                overlayScreenNo: 25,
                objectName: 'horseNo'
            },
            success: function (response) {
                var parseJSON = eval('(' + response + ')');
                var success = parseJSON.success;
                var status = parseJSON.status;
                if (success == true && status == 200) {
                    displayRunner(parseJSON.result);
                } else {
                    //alert(parseJSON.msg);
                }
            }
        });
    }

    $("#enterRunnerPositionButton").click(function () {
        $("#enterRunnerPositionDialog").load('runnerPositionSelection.html', function () {
            //$("#enterRunnerPositionDialog").dialog("open");
        });
        if ($("#enterRunnerPositionDialog").dialog("isOpen")) {} else $("#enterRunnerPositionDialog").dialog("open");
    });

我希望我有HTML和访问AJAX页面的权限,但既然我没有,你就必须测试一下,并给我反馈。代码中有很多错误,修复如下。缺少括号,调用对象的次数太多(可能是错误的根源),等等

试试这个:
$dlg = $("#enterRunnerPositionDialog");
$btn = $("#enterRunnerPositionButton");
$dlg.dialog({
    autoOpen: false,
    position: 'center',
    title: 'Enter Runner Position Selection',
    draggable: false,
    width: 1000,
    height: 900,
    resizable: false,
    modal: true,
    open: function (event, ui) {
        var html = "";
        $.ajax({
            type: "GET",
            url: "AdminController",
            data: {
                overlayScreenNo: 25,
                objectName: 'horseNo'
            },
            success: function (response) {
                var parseJSON = eval('(' + response + ')');
                var success = parseJSON.success;
                var status = parseJSON.status;
                if (success === true && status === 200) {
                    displayRunner(parseJSON.result);
                } else {
                    //alert(parseJSON.msg);
                }
            }
        });
    }
});
$btn.click(function () {
    //$("#enterRunnerPositionDialog").load('runnerPositionSelection.html', function () {
    //$("#enterRunnerPositionDialog").dialog("open");
    //});
    if ($dlg.dialog("isOpen")) {
        return;
    } else {
        $dlg.dialog("open");
    }
});