Div disappears from original place after closing the dialog

早过忘川 提交于 2019-12-24 15:51:31

问题


I am trying to use jquery dialog. My requirement is to open a dialog box from a content which is already present on page.

But when I am closing an dialog box that element disappears from page. I want it to be present on the same place after closing the dialog.

Can somebody guide me on this?

Thanks Subhash


回答1:


When we call for dialog, jquery takes that div, appends it to new Dialog div, and this dialog div is appended to body and then it remains over there. Now whenever a dialog function is called same div is popped up.

So what I did, on close of dialog , I destroyed dialog div, (It removed dialog div from body). Then appended my own div to previous position.

close : function(event, ui)
            {
                $("#myDiv").dialog("destroy");
                $(this).removeClass();
                $(this).removeAttr("style");
                $(this).appendTo($("#originalParentDiv"));
            }




回答2:


I believe jQuery moved the div into the dialog when you open.

You might need to first make a copy of it and then open the dialog with the copy, and manualy update the original if you need.



来源:https://stackoverflow.com/questions/7673935/div-disappears-from-original-place-after-closing-the-dialog

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