Difference between #3 and #4 of
Ordering Models by Weight with CJuiSortable

Changes

Title unchanged

Ordering Models by Weight with CJuiSortable

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

Content changed

[...]
// Add a Submit button to send data to the controller
echo CHtml::ajaxButton('Submit Changes', '', array(
'type' => 'POST',
'data' => array(
// Turn the Javascript array into a PHP-friendly string
'Order' => 'js:$("ul
#orderList.ui-sortable").sortable("toArray").toString()',
)
));
[...]
if ($model = YourClass::model()->findbyPk($models[$i]))
{
$model->weight = $i;
 
 
                $model->save(
// Use updateByPK to avoid running model validate
 
                $model->updateByPk( $models[$i],array("weight"=>$i) 
);
}
}
}
// Handle the regular model order view
else
[...]
9 0
10 followers
Viewed: 16 489 times
Version: 1.1
Category: Tutorials
Tags:
Written by: Matt Kelliher
Last updated by: Phil Loaiza
Created on: Mar 11, 2010
Last updated: 11 years ago
Update Article

Revisions

View all history