Dropdown with a form inside with twitter-bootstrap

后端 未结 8 1597
清歌不尽
清歌不尽 2020-12-07 16:44

I have a Dropdown in my TopBar, built with the Twitter Bootstrap CSS framework.

I have 3 problems with it that I can\'t find any solution to:

  1. The text
相关标签:
8条回答
  • 2020-12-07 17:21

    In case you don't want to stop propagation of your events, or that solution didn't work for you, you can add this code somewhere near initialization of bootstrap-dropdown:

    $('html').off('click.dropdown.data-api');
    $('html').on('click.dropdown.data-api', function(e) {
      if(!$(e.target).parents().is('.dropdown-menu form')) {
        $('.dropdown').removeClass('open');
      }
    });
    
    0 讨论(0)
  • 2020-12-07 17:27

    For your third question - In your bootstrap-dropdown.js comment source code row

    $('html').on('click.dropdown.data-api', clearMenus)
    

    and write there this:

    $(document).bind('click', function(e) {
        var $clicked = $(e.target);
        if (!$clicked.hasClass("dropdown-menu") &&
                !$clicked.parents().hasClass("dropdown-menu")){
            clearMenus();
        }
    });
    
    0 讨论(0)
提交回复
热议问题