Cjuidatepicker Not Displaying ?

Hi All members,

I am posting this again since no one reply me.

i use a Link Button to "Add new client registration" using a form.

when enter data in a date field CjuiDatePicker is not displaying.?




<?php echo $form->labelEx($model,'p_end_date'); ?>

    	<?php

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

            	'model'=>$model,

                    	'value'=>'p_end_date',

            	'attribute'=>'p_end_date',

            	// additional javascript options for the date picker plugin

            	'options'=>array(

            	'showAnim'=>'fold',

            	'dateFormat'=>'yy-mm-dd',

            	),

            	'htmlOptions'=>array(

            	'style'=>'height:20px;',

            	//'value'=>'3/3/2011',

            	),

    	)); 	

    	//echo $form->textField($model,'p_end_date',array('size'=>40,'maxlength'=>100)); ?>

    	

            	<?php echo $form->error($model,'p_end_date'); ?>



First, check browser console whether it has JavaScript errors or not.

Second, check that jquery and jqueryUI are in html code of your page.

yes you follow LastDay’ words…

Check your browser console so that you can easily troubleshoot them. It should automatically include necessary js scripts.

one more thing is that in you code

[b]'value'=&gt;'p_end_date'[/b] is not a valid date. check it. But this is not a issue here

thanks for your reply.

This works fine when i clik a list of clients created using CRUD.but when i user a linkbutton it does not display.

I there is no javascript error in browser ,2nd i could not understand well so writing my link button code.




<?php echo CHtml::link('Add Client ', "",  // the link for open the dialog

	array(

    	'style'=>'cursor: pointer; font-size:20px; text-decoration: underline;',

    	'onclick'=>"{addclient(); $('#dialogclient').dialog('open');}"));

?>



@lex p&ian;

yes browser console is working fine.

actual problem when i use link a new dialog opens for it .i enter all data only date field value not displaying the calendar.

thanks plz advise.

If you could uploud this page somewhere - then it would be perfect. Can’t see what is wrong in your code according to your posts in this theme.

I have date field in a registration form with cjuidatepicker widget. This widget working well in a static page, but when I use it in a popup form, this widget does not appear.

Any advice would be appreciated.

A Link to open a pop-up dialog, its code is here.




<?php

	echo CHtml::link('Add Client ', "",  

    	array(

        	'style'=>'cursor: pointer; font-size:20px; text-decoration: underline;',

        	'onclick'=>"{addclient(); $('#dialogclient').dialog('open');}"

    	)

	);

?>



cjuidatepicker widget code:




<?php

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

	'model'=>$model,

	'value'=>'p_end_date',

	'attribute'=>'p_end_date',

	// additional JavaScript options for the date picker plugin

	'options'=>array(

    	'showAnim'=>'fold',

    	'dateFormat'=>'yy-mm-dd',

	),

	'htmlOptions'=>array(

    	'style'=>'height:20px;',            	

	),

));

?>



code for rendering / opening a _from.php using url




<script type="text/javascript">

   // here is the magic

function addclient()

{

<?php echo CHtml::ajax(array(

  	**'url'=>array('client/create'),**

    	'data'=> "js:$(this).serialize()",

    	'type'=>'post',

    	'dataType'=>'json',

    	'success'=>"function(data)

    	{

        	if (data.status == 'failure')

        	{

            	$('#dialogclient div.divForForm').html(data.div);

                  	// Here is the trick: on submit-> once again this function!

            	$('#dialogclient div.divForForm form').submit(addclient);

        	}

        	else

        	{

            	$('#dialogclient div.divForForm').html(data.div);

            	setTimeout(\"$('#dialogclient').dialog('close') \",3000);

        	}


    	} ",

    	))

	?>;

	return false; 


  	}


	</script>



Actioncreate() controller CODE




 public function actionCreate()

       	{

       	$model=new client;


    	// Uncomment the following line if AJAX validation is needed

    	// $this->performAjaxValidation($model);


	if(isset($_POST['client']))

	{

    	$model->attributes=$_POST['client'];




    	if($model->save())

    	{

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

        	{

            	echo CJSON::encode(array(

                	'status'=>'success', 

                	'div'=>"Client successfully added"

                	));

            	exit;           	

        	}

        	else

            	$this->redirect(array('view','id'=>$model->id));

    	}

	}


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

	{

    	echo CJSON::encode(array(

        	'status'=>'failure', 

        	'div'=>$this->renderPartial('_form', array('model'=>$model), true)));


    	exit;           	

	}

	else

    	$this->render('create',array('model'=>$model,));

}



Just add the following code to your controller . The problem solved…

public function init(){

//load core framework scripts once, but stop them from being loaded later


//fixes big problem that many jui and related widgets cause


Yii::app()-&gt;clientScript-&gt;registerCoreScript('jquery');


Yii::app()-&gt;clientScript-&gt;registerCoreScript('jquery.ui');

}