Bootstrap下拉式关闭时点击 [英] Bootstrap dropdown closing when clicked

查看:98
本文介绍了Bootstrap下拉式关闭时点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个表单放在引导下拉列表中,但是当我点击表单中的任何一个字段时,下拉菜单就会消失。我有这段代码,但是我不知道该放在哪里,以防止下拉列表消失。

  $(函数测试(){
//设置下拉菜单
$('。dropdown-toggle')。dropdown();

//修复输入元素点击问题
$('。dropdown input,.dropdown label')。click(function(e){
e.stopPropagation();
});
});

有人可以告诉我应该把它放在哪里吗?我尝试在引导下拉列表中,我在HTML内部尝试过,但仍然不起作用。

解决方案

只需使用此示例这个解决方案适用于我。

 < script type =text / javascript> 
window.addEvent('domready',function(){
Element.prototype.hide = function(){
$(function(){
//替换标签id with myTab
//< ul id =myTabclass =nav nav-tabs>
$('#myTab li:eq(1)a')。 );
});
};
});
< / script>

希望它有所帮助。谢谢。


I put a form inside a bootstrap dropdown, but when I click any of the fields in the form, the dropdown goes away. I have this piece of code but I don't know where to put it to prevent the dropdown disappearing.

$(function test() {
  // Setup drop down menu
  $('.dropdown-toggle').dropdown();

  // Fix input element click problem
  $('.dropdown input, .dropdown label').click(function(e) {
    e.stopPropagation();
  });
});

Could someone please tell me where I should put this? I tried in the bootstrap-dropdown, I tried within the HTML but it still doesn't work.

解决方案

Simply use this example.This solution works for me.

<script type="text/javascript">
window.addEvent('domready',function() {    
   Element.prototype.hide = function() {
      $(function () { 
        // replace your tab id with myTab
        //<ul id="myTab" class="nav nav-tabs">
        $('#myTab li:eq(1) a').tab('show');
      });      
   };
});
</script>

Hope it'll help. Thanks.

这篇关于Bootstrap下拉式关闭时点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆