From 740bedc1ad21a07c8f915dec8702fe5d5d2ea2bc Mon Sep 17 00:00:00 2001 From: Rafael Ostertag <rafael.ostertag@math.uzh.ch> Date: Tue, 10 May 2016 14:25:59 +0200 Subject: [PATCH] Implemented https://project/issues/1881 --- javascript/src/QfqForm.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/javascript/src/QfqForm.js b/javascript/src/QfqForm.js index 3a151bf0c..975f4eef6 100644 --- a/javascript/src/QfqForm.js +++ b/javascript/src/QfqForm.js @@ -51,6 +51,7 @@ var QfqNS = QfqNS || {}; this.getDeleteButton().click(this.handleDeleteClick.bind(this)); this.setupFormUpdateHandler(); + this.setupEnterKeyHandler(); this.fileUploader = new n.FileUpload('#' + this.formId, this.fileUploadTo); this.fileUploader.on('fileupload.started', this.startUploadHandler); @@ -77,6 +78,22 @@ var QfqNS = QfqNS || {}; n.QfqForm.prototype.on = n.EventEmitter.onMixin; + /** + * @private + */ + n.QfqForm.prototype.setupEnterKeyHandler = function () { + $("input").keyup(function (event) { + if (event.which === 13) { + if (this.form.formChanged) { + this.getSaveButton().trigger("click"); + } + event.preventDefault(); + } + }.bind(this)); + }; + + + /** * * @private -- GitLab