Yii Framework Forum: Cjuidatepicker Not Displaying ? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cjuidatepicker Not Displaying ? form is open using a link button Rate Topic: -----

#1 User is offline   hameedhamdani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 82
  • Joined: 20-October 12
  • Location:Islambad,Pakistan

Posted 01 December 2012 - 12:46 AM

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'); ?>

0

#2 User is offline   LastDay 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 06-March 11
  • Location:Russia

Posted 01 December 2012 - 09:30 AM

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

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

#3 User is offline   @lex p&ian 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 16-December 11
  • Location:India

Posted 01 December 2012 - 01:17 PM

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
'value'=>'p_end_date' is not a valid date. check it. But this is not a issue here
1

#4 User is offline   hameedhamdani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 82
  • Joined: 20-October 12
  • Location:Islambad,Pakistan

Posted 04 December 2012 - 02:14 AM

View PostLastDay, on 01 December 2012 - 09:30 AM, said:

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

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

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');}"));
?>

0

#5 User is offline   hameedhamdani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 82
  • Joined: 20-October 12
  • Location:Islambad,Pakistan

Posted 04 December 2012 - 02:17 AM

View Post@lex p&ian, on 01 December 2012 - 01:17 PM, said:

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
'value'=>'p_end_date' is not a valid date. check it. But this is not a issue here


@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.
0

#6 User is offline   LastDay 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 06-March 11
  • Location:Russia

Posted 04 December 2012 - 04:16 AM

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.
0

#7 User is offline   hameedhamdani 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 82
  • Joined: 20-October 12
  • Location:Islambad,Pakistan

Posted 05 December 2012 - 12:51 AM

View PostLastDay, on 04 December 2012 - 04:16 AM, said:

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,));
}

0

#8 User is offline   nairgh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 05-October 13

Posted 16 February 2014 - 08:57 PM

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()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerCoreScript('jquery.ui');
}
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users