Ajax Call Outputting A Widget

I am trying to have an element on a page when clicked calls an ajax function to output a widget.

Problem: This ajax action is only outputting <div id="slider"></div>

Anyone have any idea what the issue is?

Here is the ajax call




                    var data = 'val1='+val1+'&val2='+val2;

                    $.ajax( {

                        type: 'POST',

                        url: '/mycontroller/ajaxCall',

                        data: data,

                    }).success(function(data) {

                        $('#widget-wrapper').html(data);

                    });



Here is the ajax action




    public function actionAjaxCall() {

        if (Yii::app()->request->isAjaxRequest)  {

            $this->widget('zii.widgets.jui.CJuiSlider', array(

                'id' => 'slider',

                'value' => 37,

                'options'=>array(

                    'min'=>0,

                    'max'=>99,

                ),

            )); // BUG ONLY OUTPUTS #slider div with no classes or value handle contents

        

        } else {

            $this->redirect('index');

        }

    }



Solution found:

instead of calling $this->widget in the ajax action

do that in a view file passing the parameters in partialRender with IMPORTANT false, true at the end.

Example:




$this->renderPartial('_slider', array('min' => 0, 'max' => 99, 'value' => 37,), false, true);