Fix 1503
This commit is contained in:
14
Elecciones-Web/frontend/public/bootstrap.js
vendored
14
Elecciones-Web/frontend/public/bootstrap.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
// frontend/public/bootstrap.js
|
// frontend/public/bootstrap.js
|
||||||
|
|
||||||
(function() {
|
(function () {
|
||||||
// El dominio donde se alojan los widgets
|
// El dominio donde se alojan los widgets
|
||||||
const WIDGETS_HOST = 'https://elecciones2025.eldia.com';
|
const WIDGETS_HOST = 'https://elecciones2025.eldia.com';
|
||||||
|
|
||||||
@@ -39,10 +39,10 @@
|
|||||||
if (!entryKey) {
|
if (!entryKey) {
|
||||||
throw new Error('No se encontró el punto de entrada en el manifest.');
|
throw new Error('No se encontró el punto de entrada en el manifest.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const entry = manifest[entryKey];
|
const entry = manifest[entryKey];
|
||||||
const jsUrl = `${WIDGETS_HOST}/${entry.file}`;
|
const jsUrl = `${WIDGETS_HOST}/${entry.file}`;
|
||||||
|
|
||||||
// 3. Cargar el CSS si existe
|
// 3. Cargar el CSS si existe
|
||||||
if (entry.css && entry.css.length > 0) {
|
if (entry.css && entry.css.length > 0) {
|
||||||
entry.css.forEach(cssFile => {
|
entry.css.forEach(cssFile => {
|
||||||
@@ -54,6 +54,14 @@
|
|||||||
// 4. Cargar el JS principal y esperar a que esté listo
|
// 4. Cargar el JS principal y esperar a que esté listo
|
||||||
await loadScript(jsUrl);
|
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
|
// 5. Una vez cargado, llamar a la función de renderizado
|
||||||
if (window.EleccionesWidgets && typeof window.EleccionesWidgets.render === 'function') {
|
if (window.EleccionesWidgets && typeof window.EleccionesWidgets.render === 'function') {
|
||||||
window.EleccionesWidgets.render();
|
window.EleccionesWidgets.render();
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ if (import.meta.env.DEV) {
|
|||||||
// --- MODO PRODUCCIÓN ---
|
// --- MODO PRODUCCIÓN ---
|
||||||
// Exponemos la función de renderizado para el bootstrap.js
|
// Exponemos la función de renderizado para el bootstrap.js
|
||||||
const renderWidgets = () => {
|
const renderWidgets = () => {
|
||||||
|
console.log('React: Se ha ejecutado renderWidgets.');
|
||||||
const widgetContainers = document.querySelectorAll('[data-elecciones-widget]');
|
const widgetContainers = document.querySelectorAll('[data-elecciones-widget]');
|
||||||
|
console.log(`React: Se encontraron ${widgetContainers.length} contenedores de widget.`);
|
||||||
widgetContainers.forEach(container => {
|
widgetContainers.forEach(container => {
|
||||||
const widgetName = (container as HTMLElement).dataset.eleccionesWidget;
|
const widgetName = (container as HTMLElement).dataset.eleccionesWidget;
|
||||||
if (widgetName && WIDGET_MAP[widgetName]) {
|
if (widgetName && WIDGET_MAP[widgetName]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user