Hi,
I am using the following to randomise a dataset on both page load and click of a button; however, it doesn’t seem to work.
I simply have a list of videos in a dataset and want a single random item to appear in the video player when the user first loads the page and when they click the button on the page
import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;
export function pageload(event) {
// clear any filters in the dataset
$w(“#dataset1”).setFilter(wixData.filter());
// get size of collection that is connected to the dataset
let count = $w(“#dataset1”).getTotalCount();
// get random number using the size as the maximum
let idx = Math.floor(Math.random() * count);
// set the current item index of the dataset
$w(“#dataset1”).setCurrentItemIndex(idx);
}
Any advice appreciated!