diff --git a/wagtail/documents/static_src/wagtaildocs/js/document-chooser.js b/wagtail/documents/static_src/wagtaildocs/js/document-chooser.js index ed50176748..9af31e01ea 100644 --- a/wagtail/documents/static_src/wagtaildocs/js/document-chooser.js +++ b/wagtail/documents/static_src/wagtaildocs/js/document-chooser.js @@ -6,7 +6,7 @@ function createDocumentChooser(id) { $('.action-choose', chooserElement).on('click', function() { ModalWorkflow({ - url: window.chooserUrls.documentChooser, + url: chooserElement.data('chooserUrl'), onload: DOCUMENT_CHOOSER_MODAL_ONLOAD_HANDLERS, responses: { documentChosen: function(docData) { diff --git a/wagtail/documents/templates/wagtaildocs/widgets/document_chooser.html b/wagtail/documents/templates/wagtaildocs/widgets/document_chooser.html index 78df5b689f..39a492a97f 100644 --- a/wagtail/documents/templates/wagtaildocs/widgets/document_chooser.html +++ b/wagtail/documents/templates/wagtaildocs/widgets/document_chooser.html @@ -1,5 +1,6 @@ {% extends "wagtailadmin/widgets/chooser.html" %} {% block chooser_class %}document-chooser{% endblock %} +{% block chooser_attributes %}data-chooser-url="{% url "wagtaildocs:chooser" %}"{% endblock %} {% block chosen_state_view %} {{ document.title }}