ASP.NET –回发后jQuery无法正常工作 [英] ASP.NET – jQuery is not Working after Postback

查看:140
本文介绍了ASP.NET –回发后jQuery无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Function works one time only but fails when page loads after Postback. Am I missing something with onclick method?

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

推荐答案

一个原因可能是回发后无法找到该按钮.在这种情况下,由于按钮本身不存在,因此不会调用弹出窗口.

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.

这篇关于ASP.NET –回发后jQuery无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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