Hello Raniere,
If you’re looking to do something like this: https://qumseyamajd.wixsite.com/testing/anchor-session
Here is the code:
import wixLocation from 'wix-location';
let x = 1; //Flag to determine which to go to, you can also store this in session
$w.onReady(function () {
//TODO: write your page related code here...
});
//Checks flag to see which anchor it should go to
export function button1_click(event, $w) {
if(x === 0) {
wixLocation.to('/anchor-session#anchor1'); //Linking to anchor with wixLocation API
console.log("anchor1");
x = 1;
} else {
wixLocation.to('/anchor-session#anchor3');
console.log("anchor3");
x = 0;
}
}
Explanation:
I keep a flag tracking which the last anchor that was directed to and set up a conditional statement to redirect to one of them based off of the flag.
wixLocation - here
PS. Make sure to unlike everything on your button so it doesn’t have any functionality by default.
Goodluck,
Majd