在我的脚本中无法折叠和不折叠 [英] collaps and uncollaps is not working in my script

查看:118
本文介绍了在我的脚本中无法折叠和不折叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用了Master Nested Grid View,它可以基于其Packages列出所有批次,但是Collapse/UnCollapses在我的脚本中不起作用

i have used Master Nested Grid View in my project, it can list all Lots based on its Packages, but Collapse/UnCollapses is not working in my script

错误是 .live不是一个函数,我的Jquery版本不支持,我将其更改为.On,但仍然无法正常工作,请检查我的脚本并帮助我解决问题??.

the error is .live is not a function which is not supported in my Jquery version and i have changed it into .On but still its not working, please check my script and help me whats wrong??.

脚本

<script>
    $(document).ready(function () {
        var size = $("#main #gridT > thead > tr >th").size(); // get total column
        $("#main #gridT > thead > tr >th").last().remove(); // remove last column
        $("#main #gridT > thead > tr").prepend("<th></th>"); // add one column at first for collapsible column
        $("#main #gridT > tbody > tr").each(function (i, el) {
            $(this).prepend(
                    $("<td></td>")
                    .addClass("expand")
                    .addClass("hoverEff")
                    .attr('title',"click for show/hide")
                );

            //Now get sub table from last column and add this to the next new added row
            var table = $("table", this).parent().html();
            //add new row with this subtable
            $(this).after("<tr><td></td><td style='padding:5px; margin:0px;' colspan='" + (size - 1) + "'>" + table + "</td></tr>");
            $("table", this).parent().remove();
            // ADD CLICK EVENT FOR MAKE COLLAPSIBLE
            **$(".hoverEff", this).live("click", function () {**
                $(this).parent().closest("tr").next().slideToggle(100);
                $(this).toggleClass("expand collapse");
            });
        });

        //by default make all subgrid in collapse mode
        $("#main #gridT > tbody > tr td.expand").each(function (i, el) {
            $(this).toggleClass("expand collapse");
            $(this).parent().closest("tr").next().slideToggle(100);
        });

    });
</script>

结果是

推荐答案

.live在jQuery 1.9及更高版本中已被弃用并删除.使用.on代替:

.live is deprecated and removed in jquery version 1.9 and further. use .on instead:

$("#gridT").on("click",'.hoverEff',function(){
        $(this).toggleClass("expand collapse");
        $(this).parent().closest("tr").next().slideToggle(100);
});

这篇关于在我的脚本中无法折叠和不折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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