Fix spinner button

This commit is contained in:
Michael Weimann 2023-05-11 17:52:01 +02:00 committed by Igor Scheller
parent c5317e2536
commit c4f65bfbdb
1 changed files with 22 additions and 14 deletions

View File

@ -176,21 +176,29 @@ ready(() => {
});
ready(() => {
document.querySelectorAll('.spinner-down').forEach((element) => {
const addClickHandler = (selector, onClick) => {
document.querySelectorAll(selector).forEach((element) => {
const inputElement = document.getElementById(element.dataset.inputId);
if (inputElement) {
element.addEventListener('click', () => {
inputElement.stepDown();
});
if (!inputElement || !inputElement.stepUp || !inputElement.stepDown) return;
if (inputElement.disabled || inputElement.readOnly) {
// The input element is disabled or read-only → disable the +/- button as well.
// Note that changing the "disabled" or "readonly" attributes during runtime is not yet supported.
element.setAttribute('disabled', 'disabled');
return;
}
element.addEventListener('click', () => onClick(inputElement));
});
document.querySelectorAll('.spinner-up').forEach((element) => {
const inputElement = document.getElementById(element.dataset.inputId);
if (inputElement) {
element.addEventListener('click', () => {
};
addClickHandler('.spinner-up', (inputElement) => {
inputElement.stepUp();
});
}
addClickHandler('.spinner-down', (inputElement) => {
inputElement.stepDown();
});
});