Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular UI: Dropdown not working with datepicker

I am trying to add Datepicker in dropdown as follows and have set autoClose="outsideClick". However, when any month button is pressed it toggles the dropdown. How to solve this?

Html Code:

<div class="date-wrap pull-right" dropdown auto-close="outsideClick">
                <button class="btn btn-info" dropdown-toggle>Date Picker</button>
                <div class="dropdown-menu  datepicker" role="menu">
                        <datepicker show-weeks="false" ng-model="dt"></datepicker>
                </div>
</div>

Plunker: http://plnkr.co/edit/lBn3Oo?p=preview

like image 419
Shyamal Parikh Avatar asked Mar 15 '23 11:03

Shyamal Parikh


1 Answers

You need to manually prevent click event from bubbling, so it never reaches the topmost node (document) that closes dropdown:

<div class="date-wrap pull-right" dropdown auto-close="outsideClick">
    <button class="btn btn-info" dropdown-toggle>Date Picker</button>
    <div class="dropdown-menu  datepicker" role="menu" ng-click="$event.stopPropagation()">
        <datepicker show-weeks="false" ng-model="dt"></datepicker>
    </div>
</div>

Note, ng-click="$event.stopPropagation()" that does the trick.

Demo: http://plnkr.co/edit/pPwW83Ro0u0g4dVhyZaZ?p=info

like image 147
dfsq Avatar answered Mar 31 '23 12:03

dfsq