dialog in jQuery

扶醉桌前 提交于 2019-12-13 20:18:28

问题


I have this dialog code

// load dialog to user signup
function new_user_signup()
{
    $.get("/actions/_new_user_account.php",
    function(data){
        $("#dialog").html(data);
    });
    $("#dialog").dialog({ width: 400,resizable: false, position: 'top', draggable: false,     title: 'Opret profil' });
}

if I click on X icon in the top right, and try to open my dialog again, i can't.

How to open the dialog again?


回答1:


You must use the open method to reopen the dialog:

$("#dialog").dialog('open');



回答2:


You need to initialize it once and then reopen it each time you call your function. Something like this:

// initialize dialog after page is loaded, pay attention to "autoOpen: false"
$(document).ready(function(){
    $("#dialog").dialog({ width: 400,resizable: false, position: 'top', draggable: false,     title: 'Opret profil', autoOpen: false });
});

// load dialog to user signup
function new_user_signup()
{
    $.get("/actions/_new_user_account.php",
        function(data){
            $("#dialog").html(data);
        }
    );
    $("#dialog").dialog('open');
 }


来源:https://stackoverflow.com/questions/1428896/dialog-in-jquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!