Here is the live page in question: https://www.crosslakecree.com/flashcardslanding
I am using a random function to ‘shuffle’ my deck of flash cards.
Can I filter the results? I have some entries that I have not yet translated (it’s a language learning app). I have the placeholder “Need Translation” in the ‘English’ field. I want to omit those from appearing in the flash cards deck for now.
Of course using the built-in dataset filtering tool is useless because the index numbers I am generating go from 1 to ‘total count’.
Suggestions for a work around?
My code:
import wixData from ‘wix-data’ ;
export function image2_click ( event ) {
// Add your code for this event here:
// 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 - 1 );
// set the current item index of the dataset
$w ( “#dataset1” ). setCurrentItemIndex ( idx );
}