Corrige filtrado de países por continente en el selector
This commit is contained in:
parent
86a2cdb48e
commit
91f2f409d6
1 changed files with 8 additions and 1 deletions
|
|
@ -76,6 +76,7 @@
|
|||
<a href="/feeds" class="top-link">← Volver a gestión de feeds</a>
|
||||
|
||||
<script>
|
||||
// Filtra países según continente seleccionado, robusto con tipos
|
||||
function filtrarPaisesPorContinente() {
|
||||
const continenteId = document.getElementById('continente_id').value;
|
||||
const paises = JSON.parse(document.getElementById('paises-data').textContent);
|
||||
|
|
@ -87,7 +88,8 @@
|
|||
optionNA.textContent = '— País —';
|
||||
selectPais.appendChild(optionNA);
|
||||
paises.forEach(([id, nombre, contId]) => {
|
||||
if (!continenteId || contId == continenteId) {
|
||||
// Convertimos ambos a string y número para máxima compatibilidad
|
||||
if (!continenteId || contId == continenteId || contId == Number(continenteId)) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = id;
|
||||
opt.textContent = nombre;
|
||||
|
|
@ -95,6 +97,11 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Al cargar la página, aplicar filtro si hay continente seleccionado
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
filtrarPaisesPorContinente();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue