bugfix device type list js bug
This commit is contained in:
30
app/assets/js/device-types-list.js
Normal file
30
app/assets/js/device-types-list.js
Normal file
@@ -0,0 +1,30 @@
|
||||
(() => {
|
||||
function bindDeleteButtons() {
|
||||
const buttons = document.querySelectorAll('.js-device-type-delete');
|
||||
buttons.forEach((button) => {
|
||||
if (button.dataset.deleteBound === '1') {
|
||||
return;
|
||||
}
|
||||
|
||||
button.addEventListener('click', () => {
|
||||
const id = Number(button.dataset.deviceTypeId || '0');
|
||||
if (id <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.confirm('Diesen Geraetetyp wirklich loeschen?')) {
|
||||
// TODO: AJAX-Delete implementieren
|
||||
window.alert('Loeschen noch nicht implementiert');
|
||||
}
|
||||
});
|
||||
|
||||
button.dataset.deleteBound = '1';
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', bindDeleteButtons);
|
||||
} else {
|
||||
bindDeleteButtons();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user