简体   繁体   English

在输入字段中单击时,菜单下拉菜单中的表单不会保留-Bootstrap3

[英]Form inside a menu-dropdown does not stay when clicked in the input field - Bootstrap3

I have bootstrap site I am working on and it has very typical, straight from bootstrap navbar. 我有一个正在工作的引导站点,它非常典型,直接来自引导导航栏。 One of the links in the navbar menu drops down to a login form. 导航栏菜单中的链接之一会下拉至登录表单。 However, as soon as I click inside the form, it collapses back as if it was a hyperlink. 但是,一旦我在表单内单击,它就会像超级链接一样折叠回去。 I tested it alone in a FIDDLE so I know that is not something else conflicting in my code and as you can tell it is still not working as it should. 我在FIDDLE中单独对其进行了测试,因此我知道代码中没有其他冲突,并且可以看出它仍然无法正常工作。

Does anyone know what is going on here? 有人知道这是怎么回事吗? and how to fix it. 以及如何解决。

Do I need to add a JS hook passing a show function? 我需要添加一个通过show函数的JS挂钩吗? SOmething like this didn't work 这样的事情不起作用

<script>        
    $(document).ready(function () {
        $('.dropdown-toggle').show('click') //I also tried 'focus'
    });
</script>

The fiddle works for me, but apparently not for others. 小提琴对我有用,但显然对其他人无效。 So I created a video showing you the fiddle and the bootstrap implementation as they have it in their own website (which of course it works for them ) 因此,我创建了一个视频,向您展示小提琴和bootstrap的实现,因为它们在自己的网站中拥有(当然,它们对他们有用)

SEE VIDEO HERE 在这里查看视频

AH! 啊! I found it! 我找到了! Well, anyway, here it is for anyone who may have this problem in the future, which I can see that there are many already asking this question and many using Bootstrap. 好吧,无论如何,这是给将来可能会遇到此问题的任何人的,我可以看到有很多人已经问过这个问题,并且有很多人在使用Bootstrap。

Add the following at the bottom: 在底部添加以下内容:

<script>
    $(document).on('click', '.dropdown-menu', function (e) {
        e.stopPropagation()
    })
</script>

Make sure the classes match and you are on your way! 确保课程匹配并且您正在路上!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM