【问题标题】:Multiple divs are being added to form when using jquery modal使用 jquery modal 时将多个 div 添加到表单中
【发布时间】:2013-04-20 15:42:44
【问题描述】:

我有 jquery 模态窗口。我点击 click here 参考打开此窗口,这是我的代码:

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button runat="server" Text="Button" ID="Button" />
        <a onclick ="$('#divReuse').dialog();" href="#">click here</a>
        <div id="divReuse">
            this is content of the modal window.
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

我的更新面板中有一个按钮。当我单击该按钮时,它会进行回发(异步)。在更新面板内进行此回发之后,我再次单击链接单击此处

问题是 jquery 在我的标记中添加了具有相同内容的额外 div

【问题讨论】:

  • 在 jsfiddle.net 中创建复制问题的演示。显示的代码不足
  • 无法创建类似的演示,因为我有一个asp.net代码。
  • 您在服务器上使用的代码完全不相关......它输出 html 并且可以从浏览器、view source 中的 ether 或浏览器控制台轻松获取该 html。浏览器和在浏览器中运行的脚本与asp.net没有任何连接
  • 事情是更新面板中的每个回发 $('#divReuse').dialog();函数添加新的 div。对此非常不爽。现在我必须使用另一个插件。
  • 如果您不显示创建这些元素的代码,没有人可以提供帮助......也可以在对话框关闭时删除。问题出在您的代码中,而不是对话框插件

标签: jquery asp.net jquery-ui updatepanel modal-dialog


【解决方案1】:

按下关闭按钮时,我删除了 jquery 生成的 div。像这样:

 $('.ui-dialog.ui-widget.ui-widget-content.ui-corner-all').remove();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-09
    相关资源
    最近更新 更多