Yii2 CListView AjaxFiltering

I need AjaxFiltering to work in my ListView in Yii2. It worked with Yii 1.

In Yii1 I used this example to get it working: http://www.yiiframework.com/wiki/185/clistview-ajax-filtering/

This is pretty important to get my project working. I’m not so familiar with Yii2 yet.


My JS Code:


$script = <<< JS


hair = &#036;('.hairFilter').serialize();

if (hair == ''){



    {data: 'hair%5B%5D=1&amp;hair%5B%5D=2&amp;hair%5B%5D=3&amp;hair%5B%5D=4'}



else {



        {data: hair}







Dropdown code for changing results:

[b] <div class="col-md-2">

&lt;?= Html::activeDropDownList(&#036;searchModel, 'hair_id',

  ArrayHelper::map(ProfileHair::find()-&gt;all(), 'id', 'name'),


  ); ?&gt;


ListView code:



         'dataProvider' =&gt; &#036;dataProvider,

         'itemOptions' =&gt; ['class' =&gt; 'item'],

         'itemView' =&gt; '_item_view',

         'pager' =&gt; [

            'class' =&gt; &#092;kop&#092;y2sp&#092;ScrollPager::className(),

            'id' =&gt; 'ajaxListView',

            'negativeMargin' =&gt; '400',

            'triggerText' =&gt; 'Load More',

            'triggerOffset' =&gt; 3,

            'noneLeftText' =&gt; '',




My Controller code snippet:

[b]public function actionIndex(array $hair = array()){

    if( count( &#036;hair ) &gt; 0 ){

        &#036;criteria-&gt;addInCondition( 'hair', &#036;hair );







When i change filter value i get following error: TypeError: $.fn.yiiListView is undefined

I think i’m pretty far from getting this working but any help would be appreciate!

If somebody could help me i would be very very glad. Thanks infront! Tutorial would be nice too!

Please format your sourcecode as code! [ code] [ /code]

Maybe a look at stackoverflow will help:

I tried those things but nothing helps. Anybody who can help with ajax calls and jquery stuff?