jquery对话框仅首次加载内容

时间:2014-08-14 10:00:01

标签: jquery asp.net webforms dialog

我在jquery中有以下对话框,显示面板内容,但它只是第一次加载内容。在第二次单击时,它仅显示模态叠加。如何在每次点击时加载内容?

asp:Panel ID="pnlCertificate" runat="server">
   <img id="imgCertificate" runat="server" style="position: relative;" /> 
</asp:Panel>

<div style="display: none">
   <div id="openDialog" style="text-align: center; position: relative; width: 956px; overflow-x: auto;">
   </div>
</div>


function viewCertificate() {
        $("#openDialog").dialog({
            modal: true,
            draggable: false,
            width: 1000,
            height: 700,
            autoOpen: true,
            open: function () {
                $('#openDialog').append($("[id$=pnlCertificate]").html());
                $('.ui-dialog-buttonpane').addClass('dialogButton');
                $('.ui-dialog-titlebar').addClass('dialogTitle');
            },
            close: function (event, ui) {
                $("#openDialog").remove();
            },
            buttons: [
            {
                text: "Print",
                "class": 'printButton',
                click: function () {

                }
            },
            {
                text: "Close",
                "class": 'closeButton',
                click: function () {
                    $(this).dialog("close");
                }
            }
          ]
        });
        $("[id$=btnPreview]").click(function (event) {
            event.preventDefault();
            $("#openDialog").dialog("open");
        });
    }

1 个答案:

答案 0 :(得分:0)

不是.remove()摧毁你的容器?试试.empty()吧?