Created
January 28, 2015 22:28
-
-
Save rafaell-lycan/f841018c5118c39d8845 to your computer and use it in GitHub Desktop.
AngularJS - Prevent Enter Submit Directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('app',[]) | |
.directive('preventEnterSubmit', function () { | |
return function (scope, el, attrs) { | |
el.bind('keydown', function (event) { | |
if (13 == event.which) { | |
event.preventDefault(); // Doesn't work at all | |
window.stop(); // Works in all browsers but IE... | |
document.execCommand('Stop'); // Works in IE | |
return false; // Don't even know why it's here. Does nothing. | |
} | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
super