I’ve encountered an issue where I can’t seem to access data(‘swiper’). I’m working in Elementor and using the Carousel slider, which appears when Nested Elements are enabled in the settings.
The task involves opening a popup and scrolling to the 3rd slide when a button on the homepage is clicked (similarly, I plan to do the same for the 4th and 5th slides). I’ve written some code that checks if it’s the correct popup when the popup opens, and then I should access data(‘swiper’) to ultimately switch to the 3rd slide.
<script>
jQuery(document).ready(function($) {
$('.button-slide-to-3').click(function() {
jQuery( document ).on( 'elementor/popup/show', ( event, id, instance ) => {
if ( id === 2090 ) {
console.log('open');
const swiper_target = jQuery('#popup_slider .e-n-carousel');
console.log(swiper_target);
const swiperInstance = swiper_target.data('swiper');
console.log(swiperInstance);
swiperInstance.slideTo(2);
}
});
});
});
</script>
I’ve done a lot of searching online, but I haven’t been able to find any information. If you have any ideas, I would greatly appreciate it if you could share them. Thank you sincerely!
Denis Radysh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.