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:


 <?php

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

        'name' => 'start_date',

        'value' => '', 

        'options' => array(

            'onClose' => CHtml::ajax(

                array(

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

                    'url'=>Yii::app()->createUrl('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:


jQuery('#start_date').datepicker({'onClose':'jQuery.ajax({\'url\':\'/hiperx/index.php/analysis/dynamicc\',\'data\':\'08/01/2013\',\'type\':\'post\',\'cache\':false,\'success\':function(html){jQuery(\"#result\").html(html)}});'});

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.

Cheers

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) {

		            $('#result').html(result);

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

                

        "),