First time working in corvid and I’m trying to get a button to change to a specific slide. The slide deck is saying not valid selector though I’m using the property ID listed (yes I checked the cases). I feel like I’m probably just doing something obvious. Any ideas what I did wrong?
Thanks!
Look at the name of the element itself next to the slide arrows. You need to add the ‘#’ to your element name and also it is just the slide number.
You can see more about it here.
https://www.wix.com/corvid/reference/$w.Slideshow.html#changeSlide
Examples
Move to a new slide using an index
This example moves to the third slide in the slideshow.
$w("#mySlideshow").changeSlide(2);
Plus looking at your code used, you can delete lines 4 and 5.
Along with moving the change slide part from $w… to line 9 and deleting the add your code…
So on line 8 you just have your export function and it ends that line with the opening curly bracket of {
Keep line 10 as it is with the closing curly bracket of }
Thank you! I knew it was something stupid. I hadn’t cleaned up the rest of it because it was bugging me so much. I think I’ve almost got it.
Now it says: Failed to get data from (new) server: SyntaxError: Unexpected token < in JSON at position 0
when I preview it.
Any idea why?
Your patience is appreciated. I’m new to programming in general and this function is pretty essential for the site I’m building so I’m really thankful for the responses!
Whoops! Sorry. Attached the wrong screenshot. I’ve got Button A and C working fine, it’s just Button B that doesn’t.
It all works fine for me on a test site, the only noticeable thing on your code is that you are missing the ‘;’ at the end of each of your three changeSlide lines of code.
Tested on the same full width slideshow as yourself and have not changed any slide names in the settings, they are still as Slide 1, Slide 2, Slide 3.
Just make sure that you take off the autoplay function in the slideshow settings if you intend to use buttons to navigate.
You might want to take off the navigation arrows and slide buttons too.
Then just make sure that you add the onClick event handler function to all of your button elements through the properties panel for each button.
Then as you have done, just make sure that the slide numbers start from 0 and not from 1 as in the slideshow setup itself. You can read more about them being zero based here, if you have not already read it yourself.
https://www.wix.com/corvid/reference/$w.Slideshow.html#slides
So the code I used for it all to work was this below.
$w.onReady(function () {
});
export function slide1Button_click(event) {
$w("#fullWidthSlides1").changeSlide(0);
}
export function slide2Button_click(event) {
$w("#fullWidthSlides1").changeSlide(1);
}
export function slide3Button_click(event) {
$w("#fullWidthSlides1").changeSlide(2);
}