ocombe / ocModal

An angularJS modal directive & service
66 stars 16 forks source link

ocModal closes on "enter" key when an input box is focused on. #8

Closed Zettersten closed 8 years ago

Zettersten commented 9 years ago
    <script type="text/ng-template" id="partials/modal.html">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="closeModal()">&times;</button>
                <h4 class="modal-title">Modal title</h4>
            </div>
            <div class="modal-body">
                <p>One fine body&hellip;</p>
                <input type="text" ng-model="hello">
                {{hello}}
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" data-dismiss="modal" ng-click="closeModal()">Close</button>
                <button type="button" class="btn btn-success">Save changes</button>
            </div>
        </script>

Now hit "enter" inside the input element....

Everything goes to shit.

ocombe commented 9 years ago

It's probably because of the ng-click on your buttons. Try changing your "save changes" button from type=button to type=submit, this way angular should activate this one and not the close button