Skip to content

Commit

Permalink
SEEDS-498 temporary workaround for range init on edit
Browse files Browse the repository at this point in the history
  • Loading branch information
nmandrescu committed Mar 19, 2021
1 parent 05710ae commit 9d89769
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions public/js/src/enketo-webform.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,26 @@ function _init( formParts ) {
if ( settings.print ) {
gui.applyPrintStyle();
}
_initRange();
// after widgets have been initialized, localize all data-i18n elements
localize( formEl );
_countChars();
return formParts;
} );
}


/**
* temporary workaround for https://github.com/enketo/enketo-core/issues/771
*/
function _initRange() {
const rangeEls = document.getElementsByClassName("range-widget__current");
for (let i = 0; i < rangeEls.length; i++) {
const rangeEl = rangeEls[i];
const labelEl = rangeEl.closest("label");
const inputEl = labelEl === null ? null : labelEl.querySelector("input.hide");
if (inputEl !== null && inputEl.value) {
rangeEl.innerHTML = inputEl.valueAsNumber;
}
}
}

0 comments on commit 9d89769

Please sign in to comment.