From 8b5282436232bd7ea49f457dfc65a08faedb6d7a Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 13 Oct 2013 17:27:53 -0400 Subject: [PATCH] optimized datepick js code. --- extensions/jui/yii/jui/DatePicker.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/jui/yii/jui/DatePicker.php b/extensions/jui/yii/jui/DatePicker.php index ea05579..1d3012d 100644 --- a/extensions/jui/yii/jui/DatePicker.php +++ b/extensions/jui/yii/jui/DatePicker.php @@ -65,14 +65,14 @@ class DatePicker extends InputWidget if ($this->language !== false) { $view = $this->getView(); DatePickerRegionalAsset::register($view); - // do not pass in any options when creating the widget - // set the options later so that the options can be combined with regional options + + $options = Json::encode($this->clientOptions); + $view->registerJs("$('#{$this->options['id']}').datepicker($.extend({}, $.datepicker.regional['{$this->language}'], $options));"); + $options = $this->clientOptions; - $this->clientOptions = array(); + $this->clientOptions = false; // the datepicker js widget is already registered $this->registerWidget('datepicker', DatePickerAsset::className()); $this->clientOptions = $options; - $options = Json::encode($options); - $view->registerJs("$('#{$this->options['id']}').datepicker('option', $.extend({}, $.datepicker.regional['{$this->language}'], $options));"); } else { $this->registerWidget('datepicker', DatePickerAsset::className()); }