Need help from guru

I have a CListView listing many different items in an index.php. I also have filters (checkboxes) to filter items by, ex: type, colour and brand. Filters work fine. But when items are filtered, I want to refresh the filters corresponding to what types, colours and brands have those filtered items. But I just can’t figure out how to pass additional data (arrays with types, colour and brands) from function in a controller back so that they are accessible in index.php.

function in the controller, that sends back filtered item list together with types, colours and brands for them:


    public function actionFilterItems()       

    {

        

        $criteria = new CDbCriteria;


         ....      

                

        $this->render('index',array(

            'dataProvider'=>$dataProvider,

            'type'=>$type,//new type list

            'colour'=>$colour,//new colour list

            'brands'=>$brands,//new brand list

        ));                

    }

Here in index.php an ajax CListView update


                $.fn.yiiListView.update(

                    'salesListView',

                    {

                        type: 'POST',

                        url: '/catalogue/FilterItems', 

                        ...

                    }

                ) 

I have tried viewData and arrays are accessible in the _view file. But what I want is to call a js function, which would refresh all checkboxlists, but arrays $type, $colours and $brands are empty in an index.php.

‘afterAjaxUpdate’=>‘js:function(id, data) {updateFilters()}’,

function updateFilters() {

alert(<?php echo CJavaScript::encode($type) ?>); //empty

}

Please, help

You can use data atribute of options array, to pass your parametres:




$.fn.yiiListView.update(

                    'salesListView',

                    {

                        type: 'POST',

                        url: '/catalogue/FilterItems',

                        data: {},

                        ...

                    }

                ) 



data is what I pass to controller. Isn’t it? Or it’s a return data?

yah…

‘data’ is what you will send with ajax request.

my I ask you to show an example of such a request, please?

Thanks!