This works for me:
Controller: menus ,action sort()
if(isset($this->data['Menu']['sorted'])) {
$this->layout='ajax';
$sorted = $this->data['Menu']['sorted'];
$sorted = str_replace('sortable[]', "",$sorted);
$sorted = str_replace('=', "",$sorted);
$sorted = explode("&", $sorted);
foreach ($sorted as $key=>$value)
{
$this->Menu->id=$value;
$this->Menu->saveField('sort',$key);
}
View:
<form action="<?php echo $html->url('/menus/sort'); ?>" method="post">
<ul id="sortable">
<?php foreach ($menus as $row): ?>
<li style="position: relative;"
id="list_<?php echo
$row['Menu']['id'] ?>"> <?php echo $row['Menu']['name']?></li>
<?php endforeach?>
</ul>
<?php echo $ajax->sortable('sortable', array(
'tag'=>'li',
'hoverclass'=>'list_hover'
)); ?>
<?php echo $html->hidden('Menu/sorted',array('id'=>'sorted'))?>
<div class="submit"><input type="submit" value="Save"
onClick="document.getElementById('sorted').value=Sortable.serialize('sortable');"/></div>
</form>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---