I have a following CListView:
<?php echo CHtml::beginForm(); ?>
<table style="width:100%" class="cart-table">
<tr class="cart-th">...</tr>
<?php
$this->widget('zii.widgets.CListView', array(
'id'=>'cart-products',
'dataProvider'=>$dataProvider,
'enableSorting'=>false,
'enablePagination'=>false,
'summaryText'=>'',
'itemView'=>'_cartitem'
));
?>
</table>
...
And _cartitem view is the following:
<tr>
<td> ... </td>
...
<td>
<?php
echo CHtml::ajaxLink(
CHtml::image('/images/icons/delete.png', 'delete', array('style'=>'width:15px')),
Yii::app()->createUrl('/site/deleteFromCart',array('product_id'=>$data->product_id, 'ajax'=>'delete')),
array(
'type' => 'POST',
'success' => "function(data) {
$.fn.yiiListView.update('cart-products');
}"
),
array( //htmlOptions
'href' => Yii::app()->createUrl( '/site/deleteFromCart', array('product_id'=>$data->product_id, 'ajax'=>'delete'))
));?>
...
</tr>
So, I have a product cart and each product has “delete” button (image). When user clicks on this image, an Ajax call is made to appropriate controler/action (site/deleteFromCart) and given item is deleted from Cart. Afterwards I need to update given listview, but this doesn’t happen.
If I include alert(‘test’) when ‘success’, the text is altered.
Also after refresh (F5) item disappears from listview.
So, it seams that everything is working except listview update.
Thx.