fix async table header not being sent with ajax requests

This commit is contained in:
Felix Hamann 2019-06-03 16:01:18 +02:00
parent 0d50a43edf
commit 9e2aa1da80
4 changed files with 7 additions and 13 deletions

View File

@ -10,13 +10,14 @@ export class HtmlHelpers {
return response.text() return response.text()
.then( .then(
(responseText) => { (responseText) => {
const docFrag = document.createRange().createContextualFragment(responseText); const element = document.createElement('div');
element.innerHTML = responseText;
let idPrefix = ''; let idPrefix = '';
if (!options.keepIds) { if (!options.keepIds) {
idPrefix = this._getIdPrefix(); idPrefix = this._getIdPrefix();
this._prefixIds(docFrag, idPrefix); this._prefixIds(element, idPrefix);
} }
return Promise.resolve({ idPrefix, element: docFrag }); return Promise.resolve({ idPrefix, element });
}, },
Promise.reject, Promise.reject,
).catch(console.error); ).catch(console.error);

View File

@ -347,7 +347,7 @@ export class AsyncTable {
this._removeListeners(); this._removeListeners();
this._element.classList.remove(ASYNC_TABLE_INITIALIZED_CLASS); this._element.classList.remove(ASYNC_TABLE_INITIALIZED_CLASS);
// update table with new // update table with new
this._updateWrapperContents(response); this._element.innerHTML = response.element.innerHTML;
this._app.utilRegistry.setupAll(this._element); this._app.utilRegistry.setupAll(this._element);
@ -359,13 +359,6 @@ export class AsyncTable {
}).catch((err) => console.error(err) }).catch((err) => console.error(err)
).finally(() => this._element.classList.remove(ASYNC_TABLE_LOADING_CLASS)); ).finally(() => this._element.classList.remove(ASYNC_TABLE_LOADING_CLASS));
} }
_updateWrapperContents(response) {
const newPage = document.createElement('div');
newPage.appendChild(response.element);
const newWrapperContents = newPage.querySelector('#' + response.idPrefix + this._element.id);
this._element.innerHTML = newWrapperContents.innerHTML;
}
} }

View File

@ -1,6 +1,6 @@
$newline never $newline never
<div .scrolltable> <div .scrolltable>
<table *{dbsAttrs'} data-async-table-db-header=#{toPathPiece HeaderDBTableShortcircuit}> <table *{dbsAttrs'}>
$maybe wHeaders' <- wHeaders $maybe wHeaders' <- wHeaders
<thead> <thead>
<tr .table__row.table__row--head> <tr .table__row.table__row--head>

View File

@ -1,3 +1,3 @@
$newline never $newline never
<div ##{wIdent "table-wrapper"} uw-async-table> <div ##{wIdent "table-wrapper"} uw-async-table data-async-table-db-header=#{toPathPiece HeaderDBTableShortcircuit}>
^{table} ^{table}