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

前端 未结 9 531
后悔当初
后悔当初 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:46

    It's hard to force table esp. tbody to have height while it's empty. So I did it in following way.

    $( '.sortablecolumn').sortable( { connectWith: '.sortablecolumn', items: 'table > tbody > *', receive: function(ev, ui) { ui.item.parent().find('table > tbody').append(ui.item); } }); $( '.sortablecolumn' ).disableSelection();

    Key aspects are items selector and receive event handler where added item is moved into table body.

    Now it works fine.

提交回复
热议问题