Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enter key doesn't work when modal contains an input with the cursor in it #26

Open
jbernalvallejo opened this issue Nov 22, 2017 · 2 comments

Comments

@jbernalvallejo
Copy link

It works for any other key or when input is not focus. However, when both situations occur simultaneously, enter action doesn't get triggered.

@jbernalvallejo
Copy link
Author

jbernalvallejo commented Nov 22, 2017

Managed to fix the issue. As Angular already submits the form ng-submit function when pressing enter, I did a workaround to get this function calling the button action.

HTML in the modal template

 <form ng-submit="onSubmit()">
     <label>Name</label>
     <input type="text" ng-model="name"/>
</form>

JS modal config

},
onScopeReady: function(scope){
    // call button action when enter is pressed
    var self = this;
    scope.onSubmit = function () {
        self.buttons.confirm.action(scope);
    };
},
buttons: {
    confirm: {
      keys: ['enter'],
      action: function(scope) {
        // ...
        return;
      }
    }
}

@AquiburRKhan
Copy link

Thanks a lot for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants