I have created a dropdown and a user taq selection area where depending on the user choice they will get different information.
First of all clients will choose their skin type and then option 2 what sort of product they are looking for.
However, the repeater is just showing random information
This is the code I wrote
import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;
const collectionName = ‘nuevodataset’ ;
const fieldToFilterByInCollection = ‘tags’ ;
$w.onReady( function () {
setRepeatedItemsInRepeater( 20 )
$w( '#tags' ).onChange((event) => {
const selectedTags = $w( ‘#tags’ ).value
loadDataToRepeater(selectedTags)
wixData.query( 'nuevodataset' )
.limit( 20 )
.ascending( "title" )
.find()
.then((results) => {
originalDataset = results.items;
function loadDataToRepeater(selectedCategories = ) {
let dataQuery = wixData.query( ‘nuevodataset’ )
if (selectedCategories.length > 0 ) {
dataQuery = dataQuery.hasSome(fieldToFilterByInCollection, selectedCategories)
}
dataQuery
.find()
.then(results => {
const itemsReadyForRepeater = results.items;
$w( ‘#repeater1’ ).data = itemsReadyForRepeater;
const isRepeaterEmpty = itemsReadyForRepeater.length === 0
if (isRepeaterEmpty) {
$w( ‘#noResultsFound’ ).show()
} else {
$w( ‘#noResultsFound’ ).hide()
}
})
}
function setRepeatedItemsInRepeater() {
$w( ‘#repeater1’ ).onItemReady(($item, itemData) => {
$item( '#productImage' ).src = itemData.image_link;
$item( '#productImage' ).tooltip = itemData.image_link;
$item( '#productName' ).text = itemData.title
}