javascriptjqueryrequirejsdaterangepickerbootstrap-daterangepicker

daterangepicker close parent Bootstrap dropdown


I have a dropdown menu in Bootstrap with a daterangepicker input.

I have this code

$(document).on('click', 'body .dropdown-menu', function (e) {
    e.stopPropagation();
});

$('#filter-expired-range').daterangepicker();

and when i click on daterangepicker calendar day input- everything is close (daterangepicker calendar and dropdown menu)

Update 1.

html code :

<div class="btn-group mea-filters-block">
<span style="float: left; padding-top: 12px;" class="mea-info"></span>
<button type="button" class="btn dropdown-toggle btn-filter btn-link" data-toggle="dropdown"
        title="Filter">
    <i class="fa fa-filter"></i></button>
<ul class="dropdown-menu dropdown-menu-right">
    <form id="docExportFilter">
        <div class="row">
        <div class="col-sm-6" style="border-right: 1px solid #ddd">

            <p class="filterslabel"><i
                        class="fa fa-calendar-check-o"></i>
                <span>Validation date</span>
            </p>

            <div class="form-group">
                <input type="checkbox" class="" name="validDocuments" id="filter-valid">
                <label for="filter-valid">Valid documents</label>
            </div>

            <div class="form-group">
                <input type="checkbox" class="" name="expired" id="filter-expired">
                <label for="filter-valid">Expired documents</label>
            </div>

            <div class="form-group" id="filter_expired_range_container" style="display: none">
                <label for="filter-expired">Expired between dates
                    <input style="width: 100%" readonly placeholder="Any" type="text"
                           class="form-control" name="expired_range" id="filter-expired-range">
                </label>
            </div>


        </div>


        <div class="col-sm-6">
            <p class="filterslabel"><i
                        class="icon-checkmark-circle2"></i> <span>Compliance</span>
            </p>
            <div class="form-group">
                <input type="checkbox" name="compliant" class="" id="filter-compilant">
                <label for="filter-compilant">Compliant documents</label>
            </div>
            <div class="form-group">
                <input type="checkbox" name="remedialActionsRequired" class="" id="filter-remedial">
                <label for="filter-remedial">Remedial required</label>
            </div>
        </div>
            </div>

        <div class="row pt-15" style="border-top: 1px solid #ddd">
            <div class="col-sm-12 text-right">
                <a class="mea-submit btn btn-primary"><i class="fa fa-check"></i>Apply</a>
                <button class="btn btn-default" type="reset"><i class="fa fa-times"></i> Cancel</button>

            </div>
        </div>


    </form>
</ul>
</div>

UPDATE 2. Here is minimal example - i see problem is requirejs - if i test it without requirejs - it work ...

example with requirejs (don't work - select date close parent dropdown) https://jsfiddle.net/5wtLqxk9/2/

example without requirejs (work fine) https://jsfiddle.net/5wtLqxk9/1/


Solution

  •    $("div.daterangepicker").click( function(e) {
            e.stopPropagation();
        });
    

    Note: place after daterangepicker() https://jsfiddle.net/5wtLqxk9/4/

    Similar to: event bubbling in Jquery datepicker