Commit 8b528243 by Qiang Xue

optimized datepick js code.

parent 6544db48
...@@ -65,14 +65,14 @@ class DatePicker extends InputWidget ...@@ -65,14 +65,14 @@ class DatePicker extends InputWidget
if ($this->language !== false) { if ($this->language !== false) {
$view = $this->getView(); $view = $this->getView();
DatePickerRegionalAsset::register($view); 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; $options = $this->clientOptions;
$this->clientOptions = array(); $this->clientOptions = false; // the datepicker js widget is already registered
$this->registerWidget('datepicker', DatePickerAsset::className()); $this->registerWidget('datepicker', DatePickerAsset::className());
$this->clientOptions = $options; $this->clientOptions = $options;
$options = Json::encode($options);
$view->registerJs("$('#{$this->options['id']}').datepicker('option', $.extend({}, $.datepicker.regional['{$this->language}'], $options));");
} else { } else {
$this->registerWidget('datepicker', DatePickerAsset::className()); $this->registerWidget('datepicker', DatePickerAsset::className());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment