Debugging 2
This commit is contained in:
+18
-17
@@ -1,27 +1,28 @@
|
|||||||
function initPaginator() {
|
|
||||||
|
function initSorter() {
|
||||||
const form = document.getElementById('search-form-id');
|
const form = document.getElementById('search-form-id');
|
||||||
|
const sortRadios = document.querySelectorAll('.sort-radio');
|
||||||
|
|
||||||
|
console.log("Sorter geladen. Formular gefunden:", !!form, "Radios gefunden:", sortRadios.length);
|
||||||
|
|
||||||
|
if (!form) return;
|
||||||
|
|
||||||
|
sortRadios.forEach(radio => {
|
||||||
|
radio.addEventListener('change', function() {
|
||||||
|
console.log("Sortierung geändert auf:", this.value);
|
||||||
|
|
||||||
const pageInput = document.getElementById('s-res-page-input');
|
const pageInput = document.getElementById('s-res-page-input');
|
||||||
const pageButtons = document.querySelectorAll('.s-res-page-navigation .s-res-page-btn');
|
if (pageInput) {
|
||||||
|
pageInput.value = '1';
|
||||||
pageButtons.forEach(button => {
|
|
||||||
button.addEventListener('click', function() {
|
|
||||||
if (this.disabled) return;
|
|
||||||
|
|
||||||
const targetPage = this.getAttribute('data-page');
|
|
||||||
|
|
||||||
if (targetPage && form && pageInput) {
|
|
||||||
pageInput.value = targetPage;
|
|
||||||
form.submit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form.submit();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ist das DOM bereits vollständig aufgebaut?
|
|
||||||
if (document.readyState === 'loading') {
|
if (document.readyState === 'loading') {
|
||||||
// Falls noch geladen wird, auf das Event warten
|
document.addEventListener('DOMContentLoaded', initSorter);
|
||||||
document.addEventListener('DOMContentLoaded', initPaginator);
|
|
||||||
} else {
|
} else {
|
||||||
// Falls das HTML bereits komplett da ist, sofort ausführen
|
initSorter();
|
||||||
initPaginator();
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user