Swiper Slideto in framework7 and index?


I am trying to use in Framework 7 Slideto of swiper and does not work …

is this function included in the framework7?

Also I am trying to see if there is a chance to slideTo a slide with a customised data-index instead of the index order set by swiper…

The case is that I want to slide to a new slide that is included dynamically when requested because it does not exist yet… this means there are only five slides by default the rest are dynamically created and I need to move to this slide after created…

is there a way to do this with swiper in framework7?



Yes, it is included, but if you try to slide to not exisiting slide, it of course won’t work. You need to add/load slide first and then call slideTo to that slide


Yes I am doing that but it is not working only working if I use it as standalone swiper … the reason for this it is that I have a google map with markers, when I click a google marker in the map I need to slideTo this hotel slide in swiper… that has the image and info of the hotel…

because there are lot of markers sometimes I need to load the first slide only in swiper and the rest only on request will be created dynacmically… this is why I create only the slide when I click a marker on the map if this does not exist yet… in this case I use the hotel id as reference to know that does not exist yet on the swiper slider…

the problem inside framework7 is that swiper slideto does not work inside google marker functions too… so for instance if I need to call the slideto from google function onclick the slideto does not exist…

So I tried to call a global function that works from the google onclick and if I print the console.log it prints what I need but calling the function slideTo gives me the error that variable does not exist… pretty weird…

I only need to create a slide when I click a marker on the google map and slideto that slide …

2 ) the other problem is that I need to slide to a particular number not an index… is that possible in swiper to create your own custom number or data-index and slide to this instead of index as default? even if generated dynamically will work?



This sounds for me like variables scope problem in your code.

you can assign for example custom number to slide using data-number attribute, and then before calling slideTo, use something like $('.swiper-slide[data-number="413"]').index() to the required slide index


I can also recomend you to check the virtual slides swiper feature


thanks a lot for the reply!


I think this should work!! I will test it!! big thanks again Valdimir!