Default button in bootstrap modal dialog

Vimalan Jaya Ganesh

I am trying to set the default button in a bootstrap modal. Here is the code: http://plnkr.co/edit/1aLlDdL8WfkUrBVt4q31?p=preview

In the modal window, I want the Submit button to be the default.

enter image description here

I tried to follow code but did not work.

$("#userNameModal").keyup(function(event){
       if(event.keyCode == 13){
           $("#submitUserNameBtn").click();
       }
});

Any help is appreciated.

johnnyarguelles

Since you are using Angular i would just use a directive. That way you can use it across your app (also at the bottom is the link for the working plnkr):

.directive('enterSubmit', function() {
    return {
        restrict: 'A',
        link: function(scope, elem, attrs) {
            elem.bind('keydown', function(event) {
                var code = event.keyCode || event.which;
                if (code === 13) {
                    if (!event.shiftKey) {
                        event.preventDefault();
                        scope.$apply(attrs.enterSubmit);
                    }
                }
            });
        }
    }
});

Then call it from you input:

enter-submit="submitUserName()"

HERE IS THE WORKING REVISED PLNKR: http://plnkr.co/edit/STXwWPxWIWpDSkIo9ruG?p=preview

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Bootstrap modal dialog button click event triggering on modal open

From Dev

href in modal dialog in bootstrap

From Dev

Validation in bootstrap modal dialog

From Dev

bootstrap how to detect which button closed a modal dialog on 'hidden_modal_bs' event func?

From Dev

Change class of an element with a radio button in a modal (Angular UI-Bootstrap: Retrieving values from a modal dialog window)

From Dev

bootstrap how to detect which button closed a modal dialog on 'hidden_modal_bs' event func?

From Dev

Twitter Bootstrap - Center Modal Dialog

From Dev

Using Bootstrap Clockpicker in modal dialog

From Dev

Image opens modal dialog bootstrap

From Dev

Tooltip + modal in button - bootstrap

From Dev

changing the default width of bootstrap modal

From Dev

Customizing Bootstrap default button

From Dev

closing a modal dialog on button click event

From Dev

AngularJS open modal dialog on button click

From Dev

AngularJS open modal dialog on button click

From Dev

Bootstrap modal dialog center image in body

From Dev

re-size the modal dialog in bootstrap dynamically

From Dev

Not able to access bootstrap modal dialog in Selenium Webdriver

From Dev

Minimize or collapse a bootstrap 2.3.2 modal dialog?

From Dev

PDF file to be displayed on the dialog modal via bootstrap

From Dev

time-picker in bootstrap modal dialog

From Dev

Bootstrap modal-dialog is not getting display

From Dev

Jquery close bootstrap modal dialog completedly

From Dev

Displaying a bootstrap Modal dialog from Angular Controller

From Dev

Unit testing React Bootstrap modal dialog

From Dev

re-size the modal dialog in bootstrap dynamically

From Dev

How to show a modal dialog using bootstrap

From Dev

Bootstrap modal-dialog is not getting display

From Dev

Add a confirm bootstrap modal/dialog to checkbox

Related Related

  1. 1

    Bootstrap modal dialog button click event triggering on modal open

  2. 2

    href in modal dialog in bootstrap

  3. 3

    Validation in bootstrap modal dialog

  4. 4

    bootstrap how to detect which button closed a modal dialog on 'hidden_modal_bs' event func?

  5. 5

    Change class of an element with a radio button in a modal (Angular UI-Bootstrap: Retrieving values from a modal dialog window)

  6. 6

    bootstrap how to detect which button closed a modal dialog on 'hidden_modal_bs' event func?

  7. 7

    Twitter Bootstrap - Center Modal Dialog

  8. 8

    Using Bootstrap Clockpicker in modal dialog

  9. 9

    Image opens modal dialog bootstrap

  10. 10

    Tooltip + modal in button - bootstrap

  11. 11

    changing the default width of bootstrap modal

  12. 12

    Customizing Bootstrap default button

  13. 13

    closing a modal dialog on button click event

  14. 14

    AngularJS open modal dialog on button click

  15. 15

    AngularJS open modal dialog on button click

  16. 16

    Bootstrap modal dialog center image in body

  17. 17

    re-size the modal dialog in bootstrap dynamically

  18. 18

    Not able to access bootstrap modal dialog in Selenium Webdriver

  19. 19

    Minimize or collapse a bootstrap 2.3.2 modal dialog?

  20. 20

    PDF file to be displayed on the dialog modal via bootstrap

  21. 21

    time-picker in bootstrap modal dialog

  22. 22

    Bootstrap modal-dialog is not getting display

  23. 23

    Jquery close bootstrap modal dialog completedly

  24. 24

    Displaying a bootstrap Modal dialog from Angular Controller

  25. 25

    Unit testing React Bootstrap modal dialog

  26. 26

    re-size the modal dialog in bootstrap dynamically

  27. 27

    How to show a modal dialog using bootstrap

  28. 28

    Bootstrap modal-dialog is not getting display

  29. 29

    Add a confirm bootstrap modal/dialog to checkbox

HotTag

Archive