Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling Placeholder Height with jQuery-UI Sortable

I'm using the jQuery-UI sortable component to drag table rows. Because of my requirements, I'm creating a helper element to hold multiple rows during the drag.

I seem to have this working, but the empty space inserted at the current drag position is only tall enough for a single row. Can anyone see why the placeholder isn't as tall as the content I'm dragging?

I tried setting style="height:auto" in the parent element being dragged but this has no effect.

I've posted my code on jsFiddle at http://jsfiddle.net/jCNcv/. If you try dragging the top item down, you can see that the empty placeholder under the drag position is only tall enough for a single row.

like image 310
Jonathan Wood Avatar asked Aug 22 '12 17:08

Jonathan Wood


1 Answers

The placeholder is only the height of one row because each sortable item is only one row. You can set the placeholder height during the start event to the height of your helper element.

start: function(e, ui ){
     ui.placeholder.height(ui.helper.outerHeight());
},

Updated jsfiddle http://jsfiddle.net/jCNcv/2/

like image 174
Nal Avatar answered Nov 11 '22 04:11

Nal