diff --git a/Elecciones-Web/frontend/public/bootstrap.js b/Elecciones-Web/frontend/public/bootstrap.js index 6804b9e..743523e 100644 --- a/Elecciones-Web/frontend/public/bootstrap.js +++ b/Elecciones-Web/frontend/public/bootstrap.js @@ -1,6 +1,6 @@ // frontend/public/bootstrap.js -(function() { +(function () { // El dominio donde se alojan los widgets const WIDGETS_HOST = 'https://elecciones2025.eldia.com'; @@ -39,10 +39,10 @@ if (!entryKey) { throw new Error('No se encontró el punto de entrada en el manifest.'); } - + const entry = manifest[entryKey]; const jsUrl = `${WIDGETS_HOST}/${entry.file}`; - + // 3. Cargar el CSS si existe if (entry.css && entry.css.length > 0) { entry.css.forEach(cssFile => { @@ -54,6 +54,14 @@ // 4. Cargar el JS principal y esperar a que esté listo await loadScript(jsUrl); + console.log('Bootstrap: Intentando llamar a render...'); + if (window.EleccionesWidgets && typeof window.EleccionesWidgets.render === 'function') { + console.log('Bootstrap: La función render existe. Llamando ahora.'); + window.EleccionesWidgets.render(); + } else { + console.error('Bootstrap: La función render no se encontró en window.EleccionesWidgets.'); + } + // 5. Una vez cargado, llamar a la función de renderizado if (window.EleccionesWidgets && typeof window.EleccionesWidgets.render === 'function') { window.EleccionesWidgets.render(); diff --git a/Elecciones-Web/frontend/src/main.tsx b/Elecciones-Web/frontend/src/main.tsx index c4a5205..b25799b 100644 --- a/Elecciones-Web/frontend/src/main.tsx +++ b/Elecciones-Web/frontend/src/main.tsx @@ -60,7 +60,9 @@ if (import.meta.env.DEV) { // --- MODO PRODUCCIÓN --- // Exponemos la función de renderizado para el bootstrap.js const renderWidgets = () => { + console.log('React: Se ha ejecutado renderWidgets.'); const widgetContainers = document.querySelectorAll('[data-elecciones-widget]'); + console.log(`React: Se encontraron ${widgetContainers.length} contenedores de widget.`); widgetContainers.forEach(container => { const widgetName = (container as HTMLElement).dataset.eleccionesWidget; if (widgetName && WIDGET_MAP[widgetName]) {