MDL-64573 output: ajax form event

Add an event that can be fired when an mform is about to be submitted via ajax.
This allows custom field types to perform an action when the form is submitted.

The atto text editor will reset any autosaves when the form is submitted.
This commit is contained in:
Damyon Wiese
2019-04-24 16:17:49 +08:00
parent 9d4f4f0051
commit 260565e305
16 changed files with 107 additions and 18 deletions
+6
View File
@@ -66,6 +66,12 @@ M.editor_tinymce.init_editor = function(Y, editorid, options) {
editor.onChange.add(function(ed) {
ed.save();
});
Y.use('event', 'moodle-core-event', function(Y) {
var form = Y.one(document.getElementById(editor.id)).ancestor('form');
form.on(M.core.event.FORM_SUBMIT_AJAX, function() {
editor.save();
}, this)
});
};
tinyMCE.init(options);