Skip to content

Commit cfdeda2

Browse files
authored
XWIKI-23335: The upload widget throws and error after uploading an attachment (#4324)
* Updated the attachments.js to check for existence of the element before using it
1 parent 6f89390 commit cfdeda2

File tree

1 file changed

+6
-3
lines changed
  • xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/viewers

1 file changed

+6
-3
lines changed

xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/js/xwiki/viewers/attachments.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,12 @@ require(['jquery', 'xwiki-events-bridge'], function($) {
277277
* Firing updateCount event when an attachment is successfully uploaded.
278278
*/
279279
$(document).on('xwiki:html5upload:done', function() {
280-
$("#docAttachments").data('liveData').updateEntries().then(() => {
281-
updateCount($("#docAttachments").data('liveData').data.data.count);
282-
});
280+
let attachmentSectionLivedata = $("#docAttachments");
281+
if (attachmentSectionLivedata.length) {
282+
attachmentSectionLivedata.data('liveData').updateEntries().then(() => {
283+
updateCount($("#docAttachments").data('liveData').data.data.count);
284+
});
285+
}
283286
});
284287

285288
/**

0 commit comments

Comments
 (0)