diff options
author | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2015-07-21 12:20:04 +0300 |
---|---|---|
committer | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2015-07-21 12:20:04 +0300 |
commit | 0352d10d8988f8a4fac3ecdb893250d230080125 (patch) | |
tree | 3415d3c763202ecbb249d0fef15961dd3b7a1944 | |
parent | 80a9ed2e8ccecedc35b497e20b7b53f947507743 (diff) | |
parent | ba142818b345e37721b3d9373e8dc1685e9156df (diff) |
Merge pull request #1750 from devenbansod/rfe1679
Ctrl/Alt + Enter submits Table->Insert form
-rw-r--r-- | js/functions.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/js/functions.js b/js/functions.js index b889eeedee..ee4a39d6e3 100644 --- a/js/functions.js +++ b/js/functions.js @@ -4718,3 +4718,26 @@ function isStorageSupported(type) } return false; } + +/** + * Unbind all event handlers before tearing down a page + */ +AJAX.registerTeardown('functions.js', function(){ + $(document).off('keydown', 'form input, form textarea, form select'); +}); + +AJAX.registerOnload('functions.js', function () { + /** + * Handle 'Ctrl/Alt + Enter' form submits + */ + $('form input, form textarea, form select').on('keydown', function(e){ + if((e.ctrlKey && e.which == 13) || (e.altKey && e.which == 13)) { + $form = $(this).closest('form'); + if (! $form.find('input[type="submit"]') || + ! $form.find('input[type="submit"]').click() + ) { + $form.submit(); + } + } + }); +}); |