Using Repeater button to Anchor to other page

I spent few days figuring out this and used some codes from wix bloggers and google search combined i found a way that works for me.
You need to make sure the page name in SEO setting corresponds to correct name to be able to use in wixLocation.to(“pagename”)
Also the dataset name is correct which appears when you enable DEV mode
Use the correct method to pass the variable and clear it
Also make sure page transition for anchor page is disabled
so here is what i did

Below is on repeater page…

( my dataset name is dataset1 and button on repeater is button2, Aslo in my database i have column which dictates whether that button will have information on anchor page or not ( i used Boolean data type for column name ‘hasDownloads’ true or false )

import wixLocation from ‘wix-location’ ;
import { memory } from ‘wix-storage’ ;

export function button2_click ( event , $w ) {

if ( $w ( “#dataset1” ). getCurrentItem (). hasDownloads === true ){
memory . setItem ( “key” , $w ( “#dataset1” ). getCurrentItem (). buttonName );
wixLocation . to ( ‘/downloads’ );
}

// console.log($w(“#dataset1”).getCurrentItem().buttonName);
}

Then i used below on Anchor page which is ‘downloads’

import { memory } from ‘wix-storage’

$w . onReady ( function (){

let value = memory . getItem ( “key” );
console . log ( value )
switch ( value )
{

case “Windows Version” :
$w ( “#anchor1” ). scrollTo ();

break ;
case “Housekeeping” :
$w ( “#anchor2” ). scrollTo ();

break ;
default :
break ;
}
memory . removeItem ( “key” );
});

hope this helps.

Thank you for sharing your code with the community :blush: