[solved] CJuiSortable help

So I have implemented the CJuiSortable widget but I’m unsure as to how I should update my database table with the new sort_order entries. Here is my markup:




<ul id="items" class="ui-sortable">

  <li id="7884029">Item 1</li>

  <li id="7379458">Item 2</li>

  <li id="1704208">Item 3</li>

</ul>



And my widget code:




<?php $this->widget('zii.widgets.jui.CJuiSortable', array(

	'id'=>'items',

	'items'=>$items,

	'options'=>array(

		'delay'=>100,

		'revert'=>300,

	),

)); ?>



Ideally I prefer if the sort order is applied upon moving an item, i.e. I do not want to enclose it all in a form.

It was quite simple to do in the end. I added an ‘update’ call in my ‘options’ array:


'update'=>"js:function(){

	$.ajax({

		type: 'POST',

		url: '{$this->createUrl('items/sort')}',

		data: $(this).sortable('serialize'),

	});

}",

I use the ‘serialize’ function to pass the LI ids. I also had to prefix the IDs with a name, in my case I just used “key_”. I then receive $_POST[‘key’] array in my controller and handle the IDs in there.

wondering if anyone on this thread could help me out - I think I’ve almost solved this based on the info here but am still having some trouble - I’ve created an ‘update’ call as described above but it never actually invokes the method in my controller

I fully describe the issue in this thread.

thanks!