http://www.neilcrookes.com/2009/02/09/cakephp-sequence-behavior/
To fix the problem with 0-position element movement i slightly changed jquery script provided by Neil
<script type="text/javascript">and little change in baked index function (just after foreach):
$(document).ready(function() {
$("div.index table ").tableDnD({
url: "<?php echo Router::url(array('action' => 'save_order')); ?>",
originalOrder: null,
onDragClass: "myDragClass",
onDragStart: function(table, row) {
// alert(originalOrder);
originalOrder = jQuery.inArray(row, $(".dragMe", table));
},
onDrop: function(table, row) {
var newOrder = jQuery.inArray(row, $(".dragMe", table));
if (newOrder != originalOrder) {
$.post(this.url+'/'+row.id, { 'data[<?php echo Inflector::singularize($this->name); ?>][weight]': newOrder });
}
},
});
});
</script>
$class = ' class="dragMe"';
if ($i++ % 2 == 0) {
$class = ' class="altrow dragMe"';
}