From ec160a91cb2245553d79bbc1a165ac39979e0578 Mon Sep 17 00:00:00 2001 From: Thong Bui Date: Wed, 10 Nov 2021 12:54:24 +0700 Subject: [PATCH] MDL-72966 File upload: Uncaught Error from JS when uploading the file --- lib/form/dndupload.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/form/dndupload.js b/lib/form/dndupload.js index de60baf4ade..ad8654e0ba6 100644 --- a/lib/form/dndupload.js +++ b/lib/form/dndupload.js @@ -863,7 +863,8 @@ M.form_dndupload.init = function(Y, options) { */ notifyUploadCompleted: function() { require(['core_form/events'], function(FormEvent) { - FormEvent.notifyUploadCompleted(this.filemanagerhelper.filemanager.get('id')); + const elementId = this.filemanagerhelper ? this.filemanagerhelper.filemanager.get('id') : this.options.containerid; + FormEvent.triggerUploadCompleted(elementId); }.bind(this)); }, @@ -872,7 +873,8 @@ M.form_dndupload.init = function(Y, options) { */ notifyUploadStarted: function() { require(['core_form/events'], function(FormEvent) { - FormEvent.notifyUploadStarted(this.filemanagerhelper.filemanager.get('id')); + const elementId = this.filemanagerhelper ? this.filemanagerhelper.filemanager.get('id') : this.options.containerid; + FormEvent.triggerUploadStarted(elementId); }.bind(this)); },