Renderpartial Effects On Widgets

Hi, I am trying to make a report that adds a followUp to a project. I can succesfully do this with addComments and addNotes and it works fine, but those are just text. I need a jcuidatepicker to pick a date for followUp. When I render Partial, it appears, but does not function; if I click, not datepicker comes up. If I render instead of renderPartial it appears to work, but I dont want a complete render, I want to be able to do stuff without leaving page and without rendering the full page like it does. So, the jquery seems to not be working with renderPartial, or maybe I am doing something wrong, but the others work fine and are done in the same fashion.

Thanks, Jonathan


 <?php echo "   ";

 echo CHtml::ajaxButton('Add Followup',

Yii::app()->createUrl('followUp/addFollowUp',array("id" => $model->id,)),

array(

'dataType' => 'html',

'type' => 'post',

'update' => '#follow-up'

) // ajax

); // script

?>




public function actionAddFollowUp($id)

	{

			

			

		$model=new FollowUp;

		

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

		{

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

			//$project->project_id = $id;

			//$model->user_id = yii::app()->session['userID'];


			 


			if($model->save()) {

				$this->redirect(Yii::app()->request->urlReferrer);

				//$this->redirect(array('project/view','id'=>$project->project_id));


			}

		}

		

		$this->renderPartial('create', array ('model'=>$model,false,true));

		//$this->render('create',array(

				//'model'=>$model,));


	}



Here is the actual form


<?php

/* @var $this FollowUpController */

/* @var $model FollowUp */

/* @var $form CActiveForm */

?>

<?php 




?>

<div class="form">

 

<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'follow-up-form',

	'enableAjaxValidation'=>false,

		'clientOptions' => array(

				'validateOnSubmit' => true,

				'validateOnChange' => true,)

)); ?>

	<div id="row"><?php echo $form->labelEx($model,'date'); ?>

	 	<?php 

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

	array(

		'value' => $model->date,

	   	'model'=> $model,

		'attribute'=>'date',

		'value'=>$model->date,

		'theme'=>'pool',	

		'cssFile'=>array('jquery-ui.css' ),

			'options' => array(

					'changeMonth'=>true,

			        'changeYear'=>true,

			        'showAnim'=>'fold',

			        'showButtonPanel'=>true,

			        'autoSize'=>true,

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

			        'defaultDate' => 'date',

				

		), 


		'htmlOptions'=>array(

                 'onsubmit'=>"return false;", 

                 

		'style'=>'height:30px;

			background:#B7C3D0;

			color:#00a;

			font-weight:bold;

			font-size:0.9em;

			border: 1px solid #A80;

			padding-left: 4px;'

		)

	)

);

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

	


     	<div id="note"><?php echo $form->labelEx($model,'note'); ?>

     	<?php echo $form->textArea($model,'note',array( 'rows' => 2, 'cols' =>20, 'maxlength'=>256)); ?>

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

		

		

		<?php  echo CHtml::button('Back',array('onclick'=>'js:history.go(+1);returnFalse;','style'=>'font-size: 14px;font-weight: bold;')); ?>

	 	<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> 

	 	 

	</div>

	

<?php $this->endWidget(); ?>

HI,

The widget register some javascript. That js is rendered when using render(), not when using renderPartial.

Maybe, you can add the add the script in your partial template using CClientScript.render() or renderBodyEnd (you have to find where is the js rendered in CJuiDatePicker code)

Another solution could be to copy the rendered js code, change it to bind js code to a class a not an id, then include it the view (the first one, not the partial).

That’s how i would try to solve that prob …

Hope it can help…