If I add items to the list after initializing .sortable , it does not work correctly.
See jsFiddle example
HTML example:
<div class="container"> </div> <br /> <button class="add-fields">add</button>
JS example:
$(".container").sortable({ containment: 'parent' }); $(".container").disableSelection(); $(".add-fields").click(function(){ $(".container").append("<div>sucke</div>") })
CSS example:
.container { height: 30px; width: 100%; background: blue; position: relative; float: left; } .container > div { position: relative; float: left; height: 100%; width: 80px; background-color: red; line-height: 30px; text-align: center; margin: 0; padding: 0; cursor: default; }
UPDATE
I found a related problem here http://bugs.jqueryui.com/ticket/7498
because this.floating is only defined in _create, if you start with empty sorting is considered vertical.
javascript jquery jquery-ui jquery-ui-sortable
skmasq
source share