页面没有加载到模态Dialog div

时间:2014-05-03 16:45:45

标签: javascript jquery jquery-ui

我不知道为什么我建立的模态对话框没有加载由' href'指定的页面。锚标记中的属性。

Javascript:

// let's build an info dialog!
    $( '.infolink' ).each(function() {
        var $page = $(this);
        var url = $page.attr('href');
        var $docviewer = $('<div class="stuffHolder"></div>')
        .dialog({
            open: function() {
                $( '.stuffHolder' ).load(url);
            },
            title: "Additional Information",
            position: { my: "center top", at: "center top", of: "#trbl" },
            show: true, //animates a fade in for the window
            autoOpen: false, //dialogs do not open by default
            width: 600, //sets dialog width
            height: 600, //sets dialog height
            modal: true, //disables everything below the dialog until dialog is closed
            buttons: {
                "Close Document": function() {
                    $(this).dialog("close");
                     }
            }
        });
        $page.click(function() {
            $docviewer.dialog('open');
            return false;
        });
    }); // end info dialog

HTML:

<a href="test.html" class="infolink">Load test page into modal dialog</a>

对话框加载得很好,但在加载时它完全是空的。

1 个答案:

答案 0 :(得分:0)

尝试更改:

open: function() {
            $( '.stuffHolder' ).load(url);
        },

成:

open: function() {
            $docviewer.load(url);
        },

在打开对话框之前,您还可以尝试将$ docviewer附加到正文中。这可能有所帮助。

相关问题