jQuery sortable item height

后端 未结 3 1316
灰色年华
灰色年华 2021-02-04 14:25

I\'ve got a simple jQuery sortable based on a list as follows:

  • Item 1
  • Item 2
  • Item 3
相关标签:
3条回答
  • 2021-02-04 14:57

    The following worked for me:

    stop: function(event,ui){
        ui.item.height("auto");
    }
    
    0 讨论(0)
  • 2021-02-04 15:01

    You could grab the current height of the Div being dragged, save it in a variable and assign a generic height to the DIV being dragged. Once it's placed, use the call back to reassign the height within the variable.

    var curHeight = $(div).height();  
    
    $(div).css({height: 20px;});
    

    You may also want to consider forceHelperSize

    0 讨论(0)
  • 2021-02-04 15:14

    After much hair-tearing I added this event to the sortable:

      start: function( event, ui ) {
        $( this ).sortable( 'refreshPositions' )
      },
    

    It seems to do the trick as I think start() is called after the helper has been created, so refreshing the positions resets the height. Probably jQuery should do this itself, but for now I'm happy.

    0 讨论(0)
提交回复
热议问题