【问题标题】:ASP.NET – jQuery is not Working after PostbackASP.NET – 回发后 jQuery 不工作
【发布时间】:2016-08-23 08:17:52
【问题描述】:

该功能只能使用一次,但在Postback 之后加载页面时会失败。我是否缺少 onclick 方法的内容?

我的 HTML:

        <!-- Iframe Section -->
        <div class="rmpView" id="ContentPlaceHolder1">
            <iframe src="/Tabs/tabOne.aspx?ID=0" height="500" width="100%">

                <html>
                    <head></head>
                    <body>
                        <div id="wrapper-iframe">
                            <label>Name:</label>
                            <input type="text"/>
                            <a href="javascript:void(0)" data-target="dBoxPopup" class="btn">Open Popup</a>
                        </div>
                    </body>
                </html>

            </iframe>
        </div>
        <!-- Iframe Section ENDS -->

        <!-- Popup body -->
        <div id="dBoxPopup" class="dialog-box">
            <uc1:wucPopupContent runat="server" ID="wucPopupContent" />
        </div>
        <!-- Popup body ENDS -->

我的 jQuery:

$("#ContentPlaceHolder1 iframe").load(function (e) {
    // trigger popup onclick inside the iframe BEGINS
    $(this).contents().find('.btn').on("click", function () {
        var btnHref = $(this).attr("data-target");
        javascript: popup(btnHref)
    });
    // trigger popup onclick inside the iframe ENDS
});

【问题讨论】:

    标签: javascript jquery asp.net iframe onclick


    【解决方案1】:

    一个原因可能是回帖后,找不到按钮。如果是这种情况,则不会调用弹出窗口,因为按钮本身不存在。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-23
      • 2013-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多