1

下面是我的代码,我有一个名为的加载 div dvLoading,谁能告诉我在哪里或如何在 open 属性中显示加载 div 并在打开时隐藏它?

$("#dialog-edit").dialog({
                title: 'Add',
                autoOpen: false,
                resizable: false,
                height: height,
                width: width,
                /*show: { effect: 'drop', direction: "up" },*/
                modal: true,
                draggable: true,
                open: function (event, ui) {
                    $(this).load(url);
                },
                close: function (event, ui) {
                    $(this).dialog('close');
                }
            });

谢谢

4

1 回答 1

1

这可能有效。(未测试)根据.load()文档。

$("#dialog-edit").dialog({
            title: 'Add',
            autoOpen: false,
            resizable: false,
            height: height,
            width: width,
            /*show: { effect: 'drop', direction: "up" },*/
            modal: true,
            draggable: true,
            //This function is launched when your dialog open.
            open: function (event, ui) {
                //Show the loading div on open.
                $("#dvLoading").show();
                //adding a callback function wich will be launched after the loading
                $(this).load(url,function(response, status, xhr) {
                                     if (status == "error") {
                                          var msg = "Sorry but there was an error: ";
                                          $(this).html(msg + xhr.status + " " + xhr.statusText);
                                     } else $.("#dvLoading").hide();
                                 });
            },
            close: function (event, ui) {
                $(this).dialog('close');
            }
        });
于 2013-07-25T14:08:50.510 回答