Can't reopen dropdown with one click
I have a web page made angularjs
and bootstrap
but not ui-bootstrap
.
There is drop-down list
and iframe
. The problem is that when the dropdown is open, clicking on the iframe will not automatically close the dropdown.
I followed this answer and added the following:
$(window).on('blur',function() { $('.dropdown-toggle').parent().removeClass('open'); } );
Now clicking on the iframe closes the dropdown. However, immediately after closing, clicking on the dropdown will NOT reopen the list; we have to click somewhere else than the iframe, or click the dropdown one time and then click the dropdown button again to open the list.
Sorry that I cannot reproduce the issue in the playground, but it seems a common problem that "only the second click opens the dropdown". I tried to uninstall data-toggle="dropdown"
but it didn't help.
Does anyone know that I can try and fix the problem?
source to share
I finally got it ...
Before that 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>
Note that it is bootstrap.js
absolutely necessary and 0.11.0
not sufficient for ui-bootstrap-tpls.js
.
(* By the way, I had a bug earlier (unfortunately, I don't remember clearly), which was related to the higher level version ui-bootstrap-tpls.js
. You actually need to keep in mind what ui-bootstrap-tpls.js
may be when you encounter a complex js error. *)
source to share
you can try a more "bootable" solution with
$(window).on('blur',function() {
if($('.dropdown-toggle').parent().hasClass('open')){
$(".dropdown-toggle").dropdown("toggle");
}
});
this will close the item if it is open and let the dropdown be closed for the next click to open the window.
source to share