jQueryのSortableでハマったのでメモ。
http://stackoverflow.com/questions/965083/jquery-sortable-list-wont-serialize-why
$("#foo").sortable("serialize");
でシリアライズした値が取得できなかったのですが、これは各ドラッグしたい項目ごとにidに_(アンダースコア)付きの名称を設定しないといけないんだそうです。
例:tableタグのtr(行)単位でsortableを使いたい場合
<tr id="category_<?php e($category['Category']['id']);?>">
のようにしておく。
<script type="text/javascript">
$(function() {
$("#sortable").sortable({
update : function () {
var order = $('#sortable').sortable("serialize");
$.post(url,order,function(theResponse){$('#sortable').html(theResponse);});
}
});
$("#sortable").disableSelection();
});
</script>
php:
foreach($this->params['form']['category'] as $position => $id):
$this->Category->id = $id;
$this->Category->saveField('sort_order',$position);
endforeach;
な感じでアップデートできます。
#やっぱり、QAサイトってニーズ大きいですね。。。