无法单击重新打开下拉列表 [英] Cannot re-open the drop-down list by one click
问题描述
我有一个由 angularjs
和 bootstrap
而不是 ui-bootstrap
。
有一个下拉列表
和 IFRAME
。问题是当下拉列表打开时,单击iframe将不会自动关闭下拉列表。
There is a drop-down list
and an iframe
. The problem is that when the drop-down list is open, clicking on the iframe will not automatically close the drop-down list.
我遵循此答案,并添加了以下内容:
I followed this answer and added the follows:
$(window).on('blur',function() { $('.dropdown-toggle').parent().removeClass('open'); } );
现在,点击iframe会关闭下拉列表。但是,在关闭后,点击下拉按钮将不会重新打开列表;我们必须点击iframe以外的其他位置,或点击下拉按钮一次,然后再次点击下拉按钮打开列表。
Now, clicking on the iframe does close the drop-down list. However, just after closing, clicking on the drop-down button will NOT re-open the list; we have to click on somewhere else than the iframe or click on the drop-down button once, then clicking again on the drop-down button opens the list.
对不起,我无法在操场上重现问题,但似乎常见的问题是只有第二次点击打开一个下拉列表。我试图删除 data-toggle =dropdown
,但没有帮助。
Sorry that I cannot reproduce the problem in a playground, but it seems a common problem that "only the second click opens a drop-down list". I tried to remove data-toggle="dropdown"
, but it did not help.
有谁知道什么我可以尝试解决问题?
Does anyone know what I could try to fix the problem?
推荐答案
我终于明白了...
之前,我使用了以下内容,并没有使用 bootstrap.js
Before, I used the following, and did NOT use bootstrap.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.11.0/ui-bootstrap-tpls.js"></script>.
为避免此问题中提到的问题,我需要使用:
To avoid the problem mentioned in this question, I need to use:
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.js"></script>
请注意, bootstrap.js
绝对是需要,而 0.11.0
对于 ui-bootstrap-tpls.js
是不够的。
Note that, bootstrap.js
is absolutely needed, and 0.11.0
is not enough for ui-bootstrap-tpls.js
.
(*顺便说一下,以前我曾经有一个错误(不幸的是我不清楚),这是由于不够高的版本 ui-bootstrap-tpls .js
。真的需要记住,当你遇到一个棘手的js bug时,你可能会遇到这样一个问题: ui-bootstrap-tpls.js
)
(* By the way, I had previously a bug (unfortunately I don't remember clearly), which was due to a not higher enough version ui-bootstrap-tpls.js
. Really need to keep in mind that ui-bootstrap-tpls.js
may be the issue when you meet a tricky js bug. *)
这篇关于无法单击重新打开下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!