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>
|
<a href="/feeds" class="top-link">← Volver a gestión de feeds</a>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// Filtra países según continente seleccionado, robusto con tipos
|
||||||
function filtrarPaisesPorContinente() {
|
function filtrarPaisesPorContinente() {
|
||||||
const continenteId = document.getElementById('continente_id').value;
|
const continenteId = document.getElementById('continente_id').value;
|
||||||
const paises = JSON.parse(document.getElementById('paises-data').textContent);
|
const paises = JSON.parse(document.getElementById('paises-data').textContent);
|
||||||
|
|
@ -87,7 +88,8 @@
|
||||||
optionNA.textContent = '— País —';
|
optionNA.textContent = '— País —';
|
||||||
selectPais.appendChild(optionNA);
|
selectPais.appendChild(optionNA);
|
||||||
paises.forEach(([id, nombre, contId]) => {
|
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');
|
const opt = document.createElement('option');
|
||||||
opt.value = id;
|
opt.value = id;
|
||||||
opt.textContent = nombre;
|
opt.textContent = nombre;
|
||||||
|
|
@ -95,6 +97,11 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Al cargar la página, aplicar filtro si hay continente seleccionado
|
||||||
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
filtrarPaisesPorContinente();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue