Hello everyone,
I am nearly finish with my wix homepage, only need to get search drop down ready.
So I tried to do like wix youtube tutorial
https://www.youtube.com/watch?v=Hx7_8-lRsW0
But there is the problem when I click on drop down, the database column for example like in the tutorial 'continent' , repeats the continent like
Europe
Europe
Europe
South America
Asia
So Europe should only seen one times .
Can somebody show how the database from the tutorial is built up ?
Don't think there is problem in code ...
Homepagelink
https://www.fliesenstore.at/
Thanks in advance :)
Thank you !!
Thank you @Yisrael (Wix) for help in duplicates and "All" to dropdown , made my code up and everything is working.
Now the filter function isnt working when dropdown is selected , or more exact when selecting dropdown nothing is shown :((((
Working on this issue multiple times but unfortunately didnt find the mistake in the filter function .
Would you be so kind and help me out in my mistake ?
// For full API documentation, including code examples, visit http://wix.to/94BuAAs import wixData from "wix-data"; import wixLocation from 'wix-location'; let lastFilterTitle; let lastFilterContinent; let debounceTimer; var cleanList; $w.onReady(function () { wixData.query('Holzoptik').limit(1000).find().then(res => { const uniqueTitles = getUniqueTitles(res.items); cleanList = buildOptions(uniqueTitles); cleanList.unshift({ "value": '', "label": 'Alle Fliesen' }); $w('#iFliesenoptik').options = cleanList; }) function getUniqueTitles(items) { const titlesOnly = items.map(item => item.fliesenoptik); return [...new Set(titlesOnly)]; } function buildOptions(uniqueList) { return uniqueList.map(curr => { return { label: curr , value: curr }; }); } $w("#repeater1").onItemReady(($w, dataItem, index) => { let linkToDynamicPage = dataItem.linker; $w('#button3').onClick(() => { wixLocation.to(linkToDynamicPage); }); $w('#container1').onClick(() => { wixLocation.to(linkToDynamicPage); }); }); }); export function iTitle_keyPress(event, $w) { if (debounceTimer) { clearTimeout(debounceTimer) debounceTimer = undefined; } debounceTimer = setTimeout(() => { filter($w('#iTitle').value, lastFilterContinent); }, 200); } function filter(title, optik) { if (lastFilterTitle !== title || lastFilterContinent !== optik) { let newFilter = wixData.filter(); if (title) newFilter = newFilter.contains('fliesenTitel', title); if (optik) newFilter = newFilter.eq('fliesenOptik', optik); $w('#dataset1').setFilter(newFilter); lastFilterTitle = title; lastFilterContinent = optik; } //searchbar only works with this row $w('#dataset1').setFilter(wixData.filter().contains('title', title)); } export function iFliesenoptik_change(event, $w) { filter(lastFilterTitle, $w('#iFliesenoptik').value); }
Thank you in advance !
Many thanks @Yisrael (Wix) made your explanation up and now have no duplicates in my dropdown.
Unfortunately I have two new problems in my code
1.
I dont know how to get a label where all continents are together so there is no filter when choosing it.
In the tutorial its called "All continents"
2.
When I preview my site and choose a label in my dropdown the following error occurs.
Unhandled promise rejection TypeError: Error.captureStackTrace is not a function. (In 'Error.captureStackTrace(s,s.constructor)', 'Error.captureStackTrace' is undefined)
Thank you for your help !!!
The Example: Remove duplicates from connected dropdown options will show you how to handle this problem.