Ajax Call Via Onclose Of Cjuidatepicker Problems

I’ve spent way too much time trying to figure this out and I’m going nowhere. I get a JS error in the console saying: “TypeError: s.apply is not a function”

I’m trying to trigger an Ajax call when a date is selected (onClose) on my calendar. I got it to work when I use a AjaxButton to make the call but that isn’t the goal. Now the Ajax method isn’t even getting called. Here is my code:


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

        'name' => 'start_date',

        'value' => '', 

        'options' => array(

            'onClose' => CHtml::ajax(


//                    'url' => array('analysis/dynamicc'),


                    'dataType' => 'html',

                    'data'=> '08/01/2013', //array('startDate'=>'js: $('#start_date').val()'),

                    'type' => 'post',

                    'update' => '#result'




        'htmlOptions' => array(

            'size' => '100',         // textField size

            'maxlength' => '100',    // textField maxlength




In the browser I end up with this:


I tried to figure out the JS and what it should look like but I failed. I have no idea which direction to go. Would really appreciate any hints.


Why dont you try to put JS code for ajax call on "onClose" event and let it try. Or have you tried what i said. Something like

'onClose'=>'js:function(){//your code for ajax call}',

Thanks for the suggestion, it’s working! I don’t know why I didn’t think of that. I simply used part of the code that the working button was based on so I didn’t even have to get into much of the jQuery. Here is the code:

'options' => array(

            'onClose' => "js:

	                function(){jQuery.ajax({'dataType':'html','data':{'startDate': $('#start_date').val()},'type':'post','success':function(result) {


		            },'url':'/hiperx/index.php/analysis/dynamicc','cache':false});return false;}