Create Cmaskedtextfield In Ajax Request

I want to create CMaskedTextField in ajaxRequest

In action:


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

            echo '<br>';

            $this->widget('CMaskedTextField', array(

                'model' => $model,

                'attribute' => 'phoneNumbers[1]',

                'mask' => '+380-99-999-99-99',

                'placeholder' => 'X',

                'htmlOptions' => array('class' => 'phoneNumber'),

            ));

            return;

}

Button in view:


echo CHtml::ajaxButton('+', '', 

                array(

                    'type' => 'POST',

                    'dataType' =>'text',

                    'success' => 'function(data){

                        $("#phone").append(data);

                    }',

                ),

                array()

);

It works, but not as it should. It create simple TextField. In script tag no add new code for this widget.

How to fix it?

And another question:

‘attribute’ => ‘phoneNumbers[1]’ must be, phoneNumbers[i] where i - count of the same widgets.

I tried to add in button:


'data' => "{

   'count' : $('.phoneNumber').length,

}",

but in action


isset($_POST['count']))

return false. Why?