JavaEar 专注于收集分享传播有价值的技术资料

Twitter datepicker in dropdown menu

I want to add a datepicker in dropdown menu. I use this datepicker link

Next, I added code to not close the menu when I click on inputs select date, the input disappears. How can i fix it?

$('.datepicker').datepicker({
    autoclose: true
});

$('.dropdown-toggle').dropdown();
$('.jsolr-search-result-form .dropdown input, .jsolr-search-result-form .dropdown label, .jsolr-search-result-form ul span').click(function(e) {
  e.stopPropagation();
});

1个回答

    最佳答案
  1. you could do the following:

    jQuery(function($){
        $('#dropdownMenu1').parent().on('hide.bs.dropdown', function(e){
            e.preventDefault();
        });
    });
    

    Example: http://jsfiddle.net/9qyf2/

    Note that the dropdown events are triggered on the parent element. From there on you can check which element has been clicked and prevent the default behavior if desirded. Make sure to check the bootstrap documentation on the js components: http://getbootstrap.com/javascript/#dropdowns-usage

    Hope it helps.