MOBILE: How to link a button to a slide

Hi!
I found this link below to link buttons to certain slides in a slideshow and it works perfectly on desktop. My question now is, how would this apply to mobile?

https://www.wix.com/corvid/forum/community-discussion/how-to-link-a-button-to-a-slide

I successfully added this code to link multiple buttons throughout a slideshow on desktop and then recreated the same slideshow to fit for mobile with adjusted code for the mobile-friendly view, but it gives me this error: “TypeError: $w(…).onClick is not a function”

Thanks in advance for any help!

(btw I’m not very code-savvy…)

If it was working on the desktop editor then it should be working on the mobile editor if you have only altered the elements themselves to fit mobile view etc.

If you have altered the actual code for mobile only, then have you put the onClick event handler on the correct element for your mobile layout, plus you need to be looking at using form factor and writing code for mobile or tablet devices only and not for all three of desktop, tablet and mobile.
https://www.wix.com/corvid/reference/wix-window.html#formFactor
https://support.wix.com/en/article/corvid-writing-code-that-only-runs-on-mobile-devices
https://support.wix.com/en/article/corvid-tutorial-displaying-elements-in-mobile-only

1 Like

Hi givemeawhisky!

Thanks so much for your input, I got it now. I had the form factor [ if (wixWindow.formFactor === “Mobile”) ] in the code for other mobile only elements, but didn’t move the onClick code for the slideshow into that section.

I will test it a bit further but it seems to work perfectly now, thanks again!
:slight_smile: