Asynctask JS: On errors, only replace inner part of page

This commit is contained in:
Raphael Michel
2021-02-15 18:26:05 +01:00
parent d109dde1e1
commit 9fdaf040dc
2 changed files with 23 additions and 10 deletions

View File

@@ -71,6 +71,7 @@ function async_task_check_error(jqXHR, textStatus, errorThrown) {
jqXHR.responseText.indexOf("</body")
));
form_handlers($("body"));
setup_collapsible_details($("body"));
} else if (c.length > 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("<body"),
jqXHR.responseText.indexOf("</body")
));
form_handlers($("body"));
if (respdom.filter('#page-wrapper') && $('#page-wrapper').length) {
$("#page-wrapper").html(respdom.find("#page-wrapper").html());
form_handlers($("#page-wrapper"));
setup_collapsible_details($("#page-wrapper"));
} else {
$("body").html(jqXHR.responseText.substring(
jqXHR.responseText.indexOf("<body"),
jqXHR.responseText.indexOf("</body")
));
form_handlers($("body"));
setup_collapsible_details($("body"));
}
} else if (c.length > 0) {
waitingDialog.hide();
ajaxErrDialog.show(c.first().html());

View File

@@ -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"));
});