简体   繁体   English

ASP.NET –回发后jQuery无法正常工作

[英]ASP.NET – jQuery is not Working after Postback

Function works one time only but fails when page loads after Postback . 该功能仅工作一次,但在Postback之后加载页面时失败。 Am I missing something with onclick method? 我是否缺少使用onclick方法的内容?

My HTML: 我的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 -->

My jQuery: 我的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
});

One reason could be that after the post back, the button is not able to be found. 原因之一可能是在发回帖子后,找不到按钮。 If this is the case, the popup will not be invoked since the button itself is not present. 在这种情况下,由于按钮本身不存在,因此不会调用弹出窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM