I created a slider in a template called template A, and I used it as a sub mega menu item in the menu. I use the Nav Menu widget with mega menu functionality enabled.
I have created some static content using text widgets or list icons and they are all displayed, but only the slider items are not displayed, because the css opacity is overridden. But when I edit the css code, it doesn’t run the slide but shows all the items in that slide. Is there any way to edit it?
When editing with Bricks, the slider works normally, but when viewing in the customer interface, the slider does not work. Thanks for watching. Have a nice day!
Hi @timmse,
Is there any progress on this? I have this current bug on my own site. https://testinc.nl/ (mobile menu).
The slider doesn’t open immediately, it’s under the “Vacatures” on the first item. you first have to close the menu and open it again or select a different menu item to make it open…
// FunciĂłn principal que gestiona el slider
const gestionarSlider = (menuItem) => {
const sliderEl = menuItem.querySelector('.bricks-swiper-container');
// Si no hay slider, adiĂłs
if (!sliderEl) return;
// Buscamos el PADRE (Wrapper) para encontrar las flechas que están fuera
const wrapper = sliderEl.parentElement;
const arrowNext = wrapper ? wrapper.querySelector('.bricks-swiper-button-next') : null;
const arrowPrev = wrapper ? wrapper.querySelector('.bricks-swiper-button-prev') : null;
// CASO 1: El Swiper YA existe -> Lo actualizamos
if (sliderEl.swiper) {
sliderEl.swiper.update();
if (sliderEl.swiper.navigation) sliderEl.swiper.navigation.update();
if (sliderEl.swiper.pagination) sliderEl.swiper.pagination.update();
}
// CASO 2: El Swiper NO existe -> Lo creamos nosotros
else if (window.Swiper && sliderEl.dataset.scriptArgs) {
try {
// 1. Limpieza de seguridad por si las comillas vienen mal
let jsonArgs = sliderEl.dataset.scriptArgs;
if (jsonArgs.includes('"')) {
jsonArgs = jsonArgs.replace(/"/g, '"');
}
// 2. Leemos la configuraciĂłn
const config = JSON.parse(jsonArgs);
// 3. Opciones obligatorias para Mega Menu
config.observer = true;
config.observeParents = true;
config.observeSlideChildren = true;
// --- CORRECCIÓN DE FLECHAS ---
// Si encontramos las flechas fuera, se las asignamos explĂcitamente
if (arrowNext && arrowPrev) {
config.navigation = {
nextEl: arrowNext,
prevEl: arrowPrev
};
}
// 4. Iniciamos el Swiper manualmente
new Swiper(sliderEl, config);
// Añadimos clase para evitar parpadeos
sliderEl.classList.add('swiper-initialized');
} catch (e) {
console.error("Error al iniciar Swiper manualmente:", e);
}
}
};
// --- ACTIVADORES ---
// Seleccionamos items de menĂş con hijos (Mega Menu)
const menuItems = document.querySelectorAll('.brxe-nav-nested li, .menu-item-has-children, .brxe-popup');
menuItems.forEach(item => {
let yaIniciado = false;
item.addEventListener('mouseenter', () => {
if (yaIniciado) return;
// Esperamos 50ms a que el menĂş se haga visible (display: block)
setTimeout(() => {
gestionarSlider(item);
yaIniciado = true; // Bloqueo para evitar LAG
}, 50);
});
// Soporte para Click (MĂłvil)
item.addEventListener('click', () => {
if (yaIniciado) return;
setTimeout(() => {
gestionarSlider(item);
yaIniciado = true;
}, 50);
});
});
});