summaryrefslogtreecommitdiffstats
path: root/public/javascripts
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-11-05 02:58:49 +0000
committerGo MAEDA <maeda@farend.jp>2020-11-05 02:58:49 +0000
commit785184c922c17e9bbd0f38f53e7e4881b9d2ae29 (patch)
tree77b12161cd55420e2f25d6d8fcebeb8b28b325c0 /public/javascripts
parent86633c8a11eba015cfccc194d934bbcfba00b44e (diff)
downloadredmine-785184c922c17e9bbd0f38f53e7e4881b9d2ae29.tar.gz
redmine-785184c922c17e9bbd0f38f53e7e4881b9d2ae29.zip
"Invalid form authenticity token" error when submitting an Ajax form with Ctrl+Enter (#29473).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@20255 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'public/javascripts')
-rw-r--r--public/javascripts/application.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 90a5189fe..c9b7d943d 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -855,8 +855,15 @@ $(document).on('keydown', 'form textarea', function(e) {
// Submit the form with Ctrl + Enter or Command + Return
var targetForm = $(e.target).closest('form');
if(e.keyCode == 13 && ((e.ctrlKey && !e.metaKey) || (!e.ctrlKey && e.metaKey) && targetForm.length)) {
- $(e.target).closest('form').find('textarea').blur().removeData('changed');
- targetForm.submit();
+ // For ajax, use click() instead of submit() to prevent "Invalid form authenticity token" error
+ if (targetForm.attr('data-remote') == 'true') {
+ if (targetForm.find('input[type=submit]').length === 0) { return false; }
+ targetForm.find('textarea').blur().removeData('changed');
+ targetForm.find('input[type=submit]').first().click();
+ } else {
+ targetForm.find('textarea').blur().removeData('changed');
+ targetForm.submit();
+ }
}
});