From af28ffff2f2fa7ebbeec7e4d55c9adb7b9f11292 Mon Sep 17 00:00:00 2001 From: Fred Every Date: Mon, 16 May 2022 14:48:10 +0200 Subject: [PATCH] Update video-chooser.js Hacked as per this discussion: https://github.com/neon-jungle/wagtailvideos/issues/81 --- .../static/wagtailvideos/js/video-chooser.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/wagtailvideos/static/wagtailvideos/js/video-chooser.js b/wagtailvideos/static/wagtailvideos/js/video-chooser.js index ce3e727..5bb9bb1 100644 --- a/wagtailvideos/static/wagtailvideos/js/video-chooser.js +++ b/wagtailvideos/static/wagtailvideos/js/video-chooser.js @@ -4,21 +4,18 @@ function createVideoChooser(id) { var input = $('#' + id); var editLink = chooserElement.find('.edit-link'); - $('.action-choose', chooserElement).click(function() { - ModalWorkflow({ - url: window.chooserUrls.videoChooser, - onload: VIDEO_CHOOSER_MODAL_ONLOAD_HANDLERS, - responses: { - videoChosen: function(videoData) { - input.val(videoData.id); + document.addEventListener('DOMContentLoaded', event => { + var input = $('#' + id); + let call_url = window.chooserUrls.videoChooser + input.val(); + $.ajax(call_url).done(function(data) { + let videoData = data.result + input.val(videoData.id); previewVideo.attr({ src: videoData.preview.url, alt: videoData.title }); chooserElement.removeClass('blank'); editLink.attr('href', videoData.edit_link); - } - } }); });