Jquery将在asp.net 3层的更新面板“不工作”中重新加载

Jquery to be reloaded in update panel Not Working in asp.net 3 tier

本文关键字:不工作 新加载 加载 工作 3层 net asp 将在 更新 Jquery      更新时间:2023-11-04

Masterpage.master:最后我的jquery如下

<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery-ui/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
<script src="js/iCheck/jquery.icheck.js"></script>
<script src="js/icheck-init.js" type="text/javascript"></script>

对于部分页面更新,需要重新加载Jquery

<script type="text/javascript" language="javascript">
    function pageLoad() {            
        $(function () {
            $(function () { // init
                $('.square-green input').iCheck({
                    checkboxClass: 'icheckbox_square-green',
                    radioClass: 'iradio_square-green',
                    increaseArea: '20%' // optional
                });
            });
             $("#rdbtn_img").iCheck('toggle', function () {
                $("#rdbtn_img").on('ifChecked', function (event) {
                    // shown
                });
                $("#rdbtn_img").on('ifUnchecked', function (event) {
                    // hide                
                });
            }); 
        });
    }        
</script>
<asp:UpdatePanel ID="upnl_logoupdate" runat="server">
<ContentTemplate>
<input type="radio" id="rdbtn_img" name="demo-radio"></input>
</ContentTemplate>
</asp:UpdatePanel>

关注链接链接

您的jQuery init函数被嵌套在其中的pageLoad函数隐藏。

更改

function pageLoad() {            
        $(function () {
            $(function () { // init
                $('.square-green input').iCheck({
                    checkboxClass: 'icheckbox_square-green',
                    radioClass: 'iradio_square-green',
                    increaseArea: '20%' // optional
                });
            });
             $("#rdbtn_img").iCheck('toggle', function () {
                $("#rdbtn_img").on('ifChecked', function (event) {
                    // shown
                });
                $("#rdbtn_img").on('ifUnchecked', function (event) {
                    // hide                
                });
            }); 
        });
    }        

$(function () { // init
    $('.square-green input').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
        increaseArea: '20%' // optional
    });
    $("#rdbtn_img").iCheck('toggle', function () {
        $("#rdbtn_img").on('ifChecked', function (event) {
             // shown
        });
        $("#rdbtn_img").on('ifUnchecked', function (event) {
             // hide                
        });
    });
});