I am new to WIX and to this forum. I use the Wix editor.
I have added a Pagination Bar for a CMS fed Pro Gallery (grid) which works very well. I would like to scroll back up to the top once the page changes. I am surprised that this functionally isn’t part of the Pagination function itself but appear it is not.
I have added the following code to do this:
The “onChange” event function works well but the “scrollTo” cannot be resolved by the code editor (note the “import” statement shows “wix-window-frontend” underlined.
I have tried using X-Y positions instead of the Anchor name for the scrollTo command but no good.
I have also used wix-window function which was recommended but dows not work.
Again, I am new to WIX and may be missing something obvious!
Suggestions???
Mike
import wixWindow from 'wix-window';
$w.onReady(()=>{
$w('#pagination1').onChange((e)=>{console.log(e.target.id+'-changed.');
let selValue = e.target.value;
console.log('VALUE: ', selValue );
if(selValue==='a') {$w('#myElement1_ID_HERE').scrollTo();}
else if(selValue==='b') {$w('#myElement2_ID_HERE').scrollTo();}
else if(selValue==='c') {$w('#myElement3_ID_HERE').scrollTo();}
else if(selValue==='d') {$w('#myElement4_ID_HERE').scrollTo();}
});
});
Your code should look something like this (simple code-skelleton).
If you have connected your elements with a dataset, then you will need to expand your code…
$w.onReady(()=>{
$w('#myDatasetIDhere').onReady(()=>{
$w('#pagination1').onChange((e)=>{
....your code......
});
});
});
Fabulous .
Your suggestion worked perfectly first time thru.
Thank-you very much.
Mike
1 Like