jQuery UI - 如何在对话框关闭后删除动态元素? [英] jQuery UI - How to remove dynamic element after dialog closes?

查看:245
本文介绍了jQuery UI - 如何在对话框关闭后删除动态元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net应用程序中使用对话框,替换以前使用过的'window.showModalDialog'
为什么要将.aspx页面加载到iframe中。



我想要元素内部对话框(包含iframe)被动态创建,关闭后 - 我想要删除动态元素(及其内容)。



点击(function(){
$('< div id =dialog>< iframe src =默认值对话框(
{
width:200,
height:200,
modal:true,
open:function(){},
close:function(){
$(this).remove(); //有做毁灭动态元素
}
})

return false;
});

是正确的方法吗?

解决方案

  close:function(){
$(this) (); //有做毁灭动态元素
}

这将工作正常。 .remove()调用将导致对话框在被删除之前自动被破坏。


I'm using dialog in my asp.net app, replacing of previously used 'window.showModalDialog' whats why have to load .aspx pages in to iframe.

I want element inside dialog (that contains the iframe) to be created dynamically, and after closing - I want dynamic element (and its content) to be removed.

$('#dialog_link').click(function () {
  $('<div id="dialog" ><iframe src="Default.aspx"></iframe></div>').dialog(
   {
      width: 200,
      height: 200,
      modal:true,
      open: function () { }, 
      close: function () {
        $(this).remove();//have do destroy dynamic element
      }   
   })

   return false;
});

is it right way to do it?

解决方案

close: function () {
   $(this).remove();//have do destroy dynamic element
}

This will work fine. The .remove() call will cause the dialog to be destroyed automatically before it is removed.

这篇关于jQuery UI - 如何在对话框关闭后删除动态元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆