Browse Source

Fixes #6672: `yii\bootstrap\Dropdown` should register client event handlers

tags/2.0.2
Qiang Xue 10 years ago
parent
commit
43b808a9d7
  1. 2
      CHANGELOG.md
  2. 1
      Dropdown.php
  3. 12
      Widget.php

2
CHANGELOG.md

@ -4,7 +4,7 @@ Yii Framework 2 bootstrap extension Change Log
2.0.2 under development 2.0.2 under development
----------------------- -----------------------
- no changes in this release. - Bug #6672: `yii\bootstrap\Dropdown` should register client event handlers (qiangxue)
2.0.1 December 07, 2014 2.0.1 December 07, 2014

1
Dropdown.php

@ -60,6 +60,7 @@ class Dropdown extends Widget
{ {
echo $this->renderItems($this->items, $this->options); echo $this->renderItems($this->items, $this->options);
BootstrapPluginAsset::register($this->getView()); BootstrapPluginAsset::register($this->getView());
$this->registerClientEvents();
} }
/** /**

12
Widget.php

@ -71,12 +71,22 @@ class Widget extends \yii\base\Widget
$view->registerJs($js); $view->registerJs($js);
} }
$this->registerClientEvents();
}
/**
* Registers JS event handlers that are listed in [[clientEvents]].
* @since 2.0.2
*/
protected function registerClientEvents()
{
if (!empty($this->clientEvents)) { if (!empty($this->clientEvents)) {
$id = $this->options['id'];
$js = []; $js = [];
foreach ($this->clientEvents as $event => $handler) { foreach ($this->clientEvents as $event => $handler) {
$js[] = "jQuery('#$id').on('$event', $handler);"; $js[] = "jQuery('#$id').on('$event', $handler);";
} }
$view->registerJs(implode("\n", $js)); $this->getView()->registerJs(implode("\n", $js));
} }
} }
} }

Loading…
Cancel
Save