Question

A widgets can or not be on a controller view, and some of widget affecting listView.

I have stalled on a afterAjaxUpdate JS event in CListView. The widget - is a product filter, which updating the list view. My problem is when I want to update my filters after update list view. Of course I can configure update code in List View, but I think is wrong, because this behaviors belongs to filter widget.

I tried this in widget

$("#' . $this->listViewId . '").yiiListView.settings.afterAjaxUpdate = function(id, data) {
    console.log(id, data);
};

But ListView js going below and obviously it's a bad solution.

I thinking about some public widget events, so I can address to listview widget through filter widget and put event there.

Maybe someone has faced with related problems or have better ideas? Thanks.

Était-ce utile?

La solution

Try this way to add afterAjaxUpdate method for your CListView.

<?php 
Yii::app()->clientScript->registerScript('handle_ajax_function', "
function addLoadingClass(id,result)
{
    $('.list-view-loading').show();
    $('li.previous').addClass('disable');
    $('li.next').addClass('disable');   
}
function removeLoadingClass(id,result)
{   
    $('li.previous').removeClass('disable');
    $('li.next').removeClass('disable');    
    try{
        $('.list-view-loading').hide(); 
    }catch(e){
        alert(e);
    }
}
");
?>

<?php
$this->widget('zii.widgets.CListView', array(
            'id'=>'handle',
            //'ajaxUpdate'=>false,
            'dataProvider'=>$data,
            'beforeAjaxUpdate'=>'addLoadingClass',
            'afterAjaxUpdate'=>'removeLoadingClass',
            'itemView'=>'myview',           
    )); 
?>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top