Fixed #58
This commit is contained in:
parent
238be4f85c
commit
1c8504e9f1
@ -4,6 +4,7 @@ Yii Framework 2 bootstrap5 extension Change Log
|
|||||||
2.0.4 under development
|
2.0.4 under development
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
- Bug #58: Dropdown clientEvents did not fire because they need to be bound on parent (simialbi)
|
||||||
- Bug #43: Accordion widget does not set "collapsed" class on toggle button (simialbi)
|
- Bug #43: Accordion widget does not set "collapsed" class on toggle button (simialbi)
|
||||||
- Enh #39: Add inline mode to `BaseHtml::checkboxList()` and `BaseHtml::radioList()` (WinterSilence)
|
- Enh #39: Add inline mode to `BaseHtml::checkboxList()` and `BaseHtml::radioList()` (WinterSilence)
|
||||||
- Enh #40: Breadcrumbs refactoring (WinterSilence)
|
- Enh #40: Breadcrumbs refactoring (WinterSilence)
|
||||||
|
@ -94,7 +94,6 @@ trait BootstrapWidgetTrait
|
|||||||
// 'popover', 'toast' and 'tooltip' plugins not activates via data attributes
|
// 'popover', 'toast' and 'tooltip' plugins not activates via data attributes
|
||||||
if (
|
if (
|
||||||
$this->clientOptions !== false
|
$this->clientOptions !== false
|
||||||
|| !empty($this->clientOptions)
|
|
||||||
|| in_array($name, ['popover', 'toast', 'tooltip'], true)
|
|| in_array($name, ['popover', 'toast', 'tooltip'], true)
|
||||||
) {
|
) {
|
||||||
$name = ucfirst($name);
|
$name = ucfirst($name);
|
||||||
@ -103,20 +102,21 @@ trait BootstrapWidgetTrait
|
|||||||
$view->registerJs("(new bootstrap.$name('#$id', $options));");
|
$view->registerJs("(new bootstrap.$name('#$id', $options));");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerClientEvents();
|
$this->registerClientEvents($name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers JS event handlers that are listed in [[clientEvents]].
|
* Registers JS event handlers that are listed in [[clientEvents]].
|
||||||
*/
|
*/
|
||||||
protected function registerClientEvents()
|
protected function registerClientEvents(string $name = null)
|
||||||
{
|
{
|
||||||
if (!empty($this->clientEvents)) {
|
if (!empty($this->clientEvents)) {
|
||||||
$id = $this->options['id'];
|
$id = $this->options['id'];
|
||||||
$js = [];
|
$js = [];
|
||||||
|
$appendix = ($name === 'dropdown') ? '.parentElement' : '';
|
||||||
foreach ($this->clientEvents as $event => $handler) {
|
foreach ($this->clientEvents as $event => $handler) {
|
||||||
$js[] = "document.getElementById('$id').addEventListener('$event', $handler);";
|
$js[] = "document.getElementById('$id')$appendix.addEventListener('$event', $handler);";
|
||||||
}
|
}
|
||||||
$this->getView()->registerJs(implode("\n", $js));
|
$this->getView()->registerJs(implode("\n", $js));
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ class Dropdown extends Widget
|
|||||||
public function run(): string
|
public function run(): string
|
||||||
{
|
{
|
||||||
BootstrapPluginAsset::register($this->getView());
|
BootstrapPluginAsset::register($this->getView());
|
||||||
$this->registerClientEvents();
|
$this->registerClientEvents('dropdown');
|
||||||
|
|
||||||
return $this->renderItems($this->items, $this->options);
|
return $this->renderItems($this->items, $this->options);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user