Closed voodooism closed 5 years ago
Maybe it will be better?
if ($this->clientOptions !== false && !empty($this->clientOptions()) {
$js = "jQuery('#$id').$name(" . Json::htmlEncode($this->clientOptions); . ");";
$view->registerJs($js);
}
then https://github.com/yiisoft/yii2-bootstrap/blob/master/src/BootstrapWidgetTrait.php#L77
According to bootstrap docs the call is required to enable "collapse" for an element specified: https://getbootstrap.com/docs/3.4/javascript/#via-javascript-3. If it triggers the event then it's designed like so by bootstrap team and we can't really affect it.
What steps will reproduce the problem?
I have nested collapse interface, like this:
index.php
1.php
and so on.
What is the expected result?
I want to open the collapse by Id and scroll page to it when a page is loading. It's my js code:
But scroll doesn't work this, because event
shown.bs.collapse
works not correctly.What do you get instead?
I register my js-code after all dependencies, but Collapse widget makes an inline script in HTML(see screenshot) That's why it happens. After calling this function
jQuery('#w0').collapse();
theshown.bs.collapse
event occur(although visually nothing happens). You can verify this with the following js-code.Thus, when the page is loaded,
shown.bs.collapse
event has already been triggered several times. I think this is incorrect.Finally, I can make my js-code work only by placing it at the end of the inline-script in HTML using the
$this->registerJs(<<<CODE 'mycode' CODE, View:POS_READY)
method.Since this behavior occurs for this reason, I think this is a framework problem. Or not?