Fix spinner button
This commit is contained in:
parent
c5317e2536
commit
c4f65bfbdb
|
@ -176,21 +176,29 @@ ready(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
ready(() => {
|
ready(() => {
|
||||||
document.querySelectorAll('.spinner-down').forEach((element) => {
|
const addClickHandler = (selector, onClick) => {
|
||||||
const inputElement = document.getElementById(element.dataset.inputId);
|
document.querySelectorAll(selector).forEach((element) => {
|
||||||
if (inputElement) {
|
const inputElement = document.getElementById(element.dataset.inputId);
|
||||||
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));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
addClickHandler('.spinner-up', (inputElement) => {
|
||||||
|
inputElement.stepUp();
|
||||||
});
|
});
|
||||||
document.querySelectorAll('.spinner-up').forEach((element) => {
|
|
||||||
const inputElement = document.getElementById(element.dataset.inputId);
|
addClickHandler('.spinner-down', (inputElement) => {
|
||||||
if (inputElement) {
|
inputElement.stepDown();
|
||||||
element.addEventListener('click', () => {
|
|
||||||
inputElement.stepUp();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue