From 9fdaf040dc8c61dc8c1a8fb0365bbb11de4f700b Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 15 Feb 2021 18:26:05 +0100 Subject: [PATCH] Asynctask JS: On errors, only replace inner part of page --- src/pretix/static/pretixbase/js/asynctask.js | 20 +++++++++++++++----- src/pretix/static/pretixbase/js/details.js | 13 ++++++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/pretix/static/pretixbase/js/asynctask.js b/src/pretix/static/pretixbase/js/asynctask.js index 4ec8ec867..34c630f08 100644 --- a/src/pretix/static/pretixbase/js/asynctask.js +++ b/src/pretix/static/pretixbase/js/asynctask.js @@ -71,6 +71,7 @@ function async_task_check_error(jqXHR, textStatus, errorThrown) { jqXHR.responseText.indexOf(" 0) { // This is some kind of 500/404/403 page, show it in an overlay $("body").data('ajaxing', false); @@ -146,11 +147,20 @@ function async_task_error(jqXHR, textStatus, errorThrown) { if (respdom.filter('form') && (respdom.filter('.has-error') || respdom.filter('.alert-danger'))) { // This is a failed form validation, let's just use it waitingDialog.hide(); - $("body").html(jqXHR.responseText.substring( - jqXHR.responseText.indexOf(" 0) { waitingDialog.hide(); ajaxErrDialog.show(c.first().html()); diff --git a/src/pretix/static/pretixbase/js/details.js b/src/pretix/static/pretixbase/js/details.js index 3cc8fbcc8..2c8ab2024 100644 --- a/src/pretix/static/pretixbase/js/details.js +++ b/src/pretix/static/pretixbase/js/details.js @@ -1,11 +1,8 @@ /*global $ */ -$(function () { - "use strict"; - +setup_collapsible_details = function (el) { var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]'; - - $("details summary, details summary a[data-toggle=variations]").click(function (e) { + el.find("details summary, details summary a[data-toggle=variations]").click(function (e) { if (this.tagName !== "A" && $(e.target).closest("a").length > 0) { return true; } @@ -55,4 +52,10 @@ $(function () { return false; }); }); +}; + +$(function () { + "use strict"; + + setup_collapsible_details($("body")); });