Skip to content

Commit e74b41c

Browse files
authored
Merge pull request #351 from dmitry-kulikov/fix/passing_options_to_js
Fix #350: "Select All" / "Unselect All" not shown when property hashVarLoadPosition is View::POS_READY (some options does not pass from PHP to JS)
2 parents 2346248 + d5a4be0 commit e74b41c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Change Log: `yii2-widget-select2`
66
**Date:** _under development_
77

88
- (enh #348): Standardize Krajee theme for each BS version & other style enhancements.
9+
- (bug #350): Some options do not work when `hashVarLoadPosition` is `View::POS_READY`.
910

1011
## Version 2.2.3
1112

src/Select2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ public function registerAssets()
457457
$this->_s2OptionsVar = 's2options_'.hash('crc32', $options);
458458
$this->options['data-s2-options'] = $this->_s2OptionsVar;
459459
$view = $this->getView();
460-
$view->registerJs("var {$this->_s2OptionsVar} = {$options};", $this->hashVarLoadPosition);
460+
$view->registerJs("window.{$this->_s2OptionsVar} = {$options};", $this->hashVarLoadPosition);
461461
if ($this->maintainOrder) {
462462
$val = Json::encode(is_array($this->value) ? $this->value : [$this->value]);
463463
$view->registerJs("initS2Order('{$id}',{$val});");

0 commit comments

Comments
 (0)