Hey
I want to add a new Item with AJAX with renderPartial but it doesn’t work. Thx for help
My CODE (short form):
Controller (AJAX)
public function actionCreatedestination($id)
{
if(Yii::app()->request->isAjaxRequest){
$destination = new Destination;
$destination->attributes = $_POST['Destination'];
$trip->addDestination($destination);
}
$this->renderPartial('_view', array(
'model'=>$trip,
'destination'=> $destination,
false,
true
));
}
view:
echo CHtml::ajaxSubmitButton('Add', array('trip/createdestination', 'id' => $id), array(
'type' => 'post',
),
array('id' => 'addDestination'));
$this->renderPartial('_view', array(
'model'=>$model,
'destination'=> $destination,
));
_view:
<?php foreach($model->destinations as $i => $destination) { ?>
<?php echo $destination->id; ?>
<?php } ?>