Yii Framework Forum: Bug In Cjuidatepicker Options - Yii Framework Forum

Jump to content

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

Bug In Cjuidatepicker Options CJuiDatePicker Rate Topic: -----

#1 User is offline   Johnny Gan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 197
  • Joined: 30-May 13

Posted 05 March 2014 - 01:34 PM

In CjuiDatePicker, I cannot use the option = "beforeShowDay", because this option need function return.

$this->widget('zii.widgets.jui.CJuiDatePicker', array(
			'model'=>$model,
			'attribute'=>'user_end_date',
			'options'   => array(
				'changeYear' => true,
				'dateFormat' => 'mm/dd/yy',
				//'timeFormat' => '',//'hh:mm tt' default
				//'beforeShowDay'=>'function(selectedDate){var disabledDates = ["04/30/2014", "05/01/2014"];for (var i = 0; i < disabledDates.length; i++) {if (new Date(disabledDates[i]).toString() == selectedDate.toString()){return false;}}return true;}',
				//'beforeShowDay'=>'editDays',
				'beforeShowDay'=>'function(a){a=a.getDay();return[a>0&&a<6,""]}',
			),
		));


But in CJuiDatePicker, it always return option value in a string value, which cannot call the function properly.


See
http://api.jqueryui....n-beforeShowDay

to see more details about datepicker api.

My suggestion is try to put "beforeShow" and "beforeShowDay" in a separate way to deal with.

Below line should be fixed in CJuiDatePicker.php
$options=CJavaScript::encode($this->options);

0

#2 User is offline   FrancisB 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 28-November 12

Posted 05 March 2014 - 07:32 PM

Hey Johnny, try put "js:" before it

'beforeShowDay'=>'js:function(a){a=a.getDay();return[a>0&&a<6,""]}',

1

#3 User is offline   Johnny Gan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 197
  • Joined: 30-May 13

Posted 06 March 2014 - 09:23 AM

View PostFrancisB, on 05 March 2014 - 07:32 PM, said:

Hey Johnny, try put "js:" before it

'beforeShowDay'=>'js:function(a){a=a.getDay();return[a>0&&a<6,""]}',



Thank you, I tested that, and it works. That's awesome!
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