I wrote a search and data selection based on a post from here
I got “the error WDE0025: The categoria collection does not exist. You cannot work with a collection using the Data API before it is created in the Editor”
The collection is not the field name? here is the code i wrote in the dataset1 is a field called “categoria” this field must give me the ability to select between national and international contenders.
import wixData from “wix-data”;
$w.onReady(() => {
loadCategoria();
});
let lastFilterNombrerelato;
let lastFilterCategoria
let debounceTimer;
export function Irelato_keyPress_1(event, $w) {
if (debounceTimer){
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#Irelato’).value);},500);
}
export function dropdown1_change(event, $w) {
filter(lastFilterNombrerelato, $w(‘#dropdown1’).value);
}
function filter (nombrerelato, categoria){
if (lastFilterNombrerelato !== nombrerelato || lastFilterCategoria !== categoria) {
let newFilter = wixData.filter();
if (nombrerelato)
newFilter = newFilter.contains(‘nombrerelato’, nombrerelato);
if (categoria)
newFilter = newFilter.contains(‘categoria’, categoria)
$w(‘#dataset1’).setFilter(newFilter);
lastFilterNombrerelato = nombrerelato;
lastFilterCategoria = categoria;
}
}
function loadCategoria (){
wixData.query(‘categoria’)
.find()
.then(res => {
let options = [{“values”:‘’,“label”:‘todos’}];
options.push(…res.items.map(categortia => {
return {“value”: categortia.title, “label”:
categortia.title};
}));
$w(‘#dropdown1’).options = options;
});
}