Jquery ui-sortable - unable to drop tr in empty tbody

前端 未结 9 555
后悔当初
后悔当初 2021-02-01 19:43

I have two connected tbody elements allowing me to drag rows between two tables. Everything works fine until all rows are removed from either table.

When all rows have

9条回答
  •  长情又很酷
    2021-02-01 19:47

    Checkout my post about this - you can solve it by attaching a method to the click which adds height to empty containers:

    function sortAndDrag() {
    
        //show BEFORE sortable starts
         $(".sortableClass").bind('click mousedown', function(){
              $(".sortableClass"").each(function (c) {
                    if ($("tbody", this).size() == 0) {
                        $(this).addClass("aClassWhichGivesHeight")
                    }
                })
         });
    
        //enable sortable
        $(".sortableClass").sortable({
            connectWith: ".sortableClass",
            stop: function (a, d) {
                $("tbody").removeClass("aClassWhichGivesHeight");
            }
        });
    
    }
    

    Something like that?

提交回复
热议问题