Shyamal Parikh
Shyamal Parikh

Reputation: 3068

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

Upvotes: 4

Views: 2448

Answers (1)

dfsq
dfsq

Reputation: 193261

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

Upvotes: 7

Related Questions