admin管理员组文章数量:1327481
How do I refresh the page when user close the drop down menu on click outside of it.
UPDATE
<li class="dropdown" id="u_pic_link">
<script>
$('#u_pic_link').on('hidden.bs.dropdown', function () {
window.location.reload();
})
</script>
How do I refresh the page when user close the drop down menu on click outside of it.
UPDATE
<li class="dropdown" id="u_pic_link">
<script>
$('#u_pic_link').on('hidden.bs.dropdown', function () {
window.location.reload();
})
</script>
Share
Improve this question
edited Jul 24, 2015 at 12:33
Sahan Perera
asked Jul 24, 2015 at 12:12
Sahan PereraSahan Perera
1942 gold badges5 silver badges17 bronze badges
3
-
there is no select it has only
<a>
and<ul>
– Sahan Perera Commented Jul 24, 2015 at 12:35 -
@SahanPerara OP is talking about a Bootstrap dropdown. Not a
<select>
element – Turnip Commented Jul 24, 2015 at 12:37 -
I found the mistake, script should be nested with
$(document).ready(function() {
– Sahan Perera Commented Jul 24, 2015 at 12:57
2 Answers
Reset to default 5You can use the hide.bs.dropdown
or hidden.bs.dropdown
events...
<ul class="nav navbar-nav">
<li class="dropdown user-dropdown" id="u_pic_link">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>...</li>
</ul>
</li>
</ul>
$('#u_pic_link').on('hidden.bs.dropdown', function () {
window.location.reload();
})
DEMO
If for whatever reason you need to place your javascript before the element you must use jQuery's document.ready event...
$(document).ready(function() {
$('#u_pic_link').on('hidden.bs.dropdown', function () {
window.location.reload();
})
})
You can listen for an event which gets fired when the dropdown is hidden.
$('#myDropdown').on('hide.bs.dropdown', function () {
// do something…
window.location.reload();
});
Official bootstrap documentation http://getbootstrap./javascript/#dropdowns
Hope this helps
本文标签: javascriptBootstrap How to refresh the page when dropdown menu is closingStack Overflow
版权声明:本文标题:javascript - Bootstrap How to refresh the page when drop-down menu is closing - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742202587a2432236.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论