Page 1 of 1

Kann nicht zum nächsten eingereicht werden nach offener Select2-Bootstrap-Theme

Posted: 23 Apr 2025, 10:00
by Anonymous
Ich kann nicht zum nächsten Feld wechseln, wenn ich Select2 öffne. Außerdem wechselt der Cursor nicht automatisch zum Suchfeld.

Code: Select all

 $(document).on('keydown', 'input, select, button', function(e) {
if (e.key === "Enter") {
const fields = $('input, select, button').filter(':visible'); // Select all visible fields
const currentIndex = fields.index(this); // Find the index of the currently focused field
let nextIndex = currentIndex + 1; // Start looking at the next field

while (nextIndex < fields.length) {
const nextField = fields[nextIndex]; // Get the next field

if (!nextField.readOnly) {
const $next = $(nextField);

if ($next.is('button') && $next.attr('id') === 'submit-form') {

// window.alert("document.getElementById.submit();");

var self = $(this);
form = self.parents('form:eq(0)');
form.submit();
// return;
} else {
e.preventDefault();
}

if ($next.is('button') && $next.attr('id') === 'calc') {
getCalculate();
}

nextField.focus();
break;
}

nextIndex++;
}
}
});

Dies funktioniert mit Eingabe- und normaler Select-Taste und funktioniert nicht mit Select2-Bootstrap-Themen