Here is the link to my page:
https://pnitake.wixsite.com/mysite-1/cofa
My objective:
- Utilize the drop down menu to filter.
- Connect the search bar to a database.
- I’d like the repeater to ONLY display the content if the title is typed in correctly.
- And I’d like the repeater button to correspond to the searched item.
My current problems:
- Something is wrong with my code.
- Search bar is not working properly.
- Drop down menu is not working properly.
- The button is somehow linked to the same PDF file no matter what is searched, and no matter what is selected in the drop down menu.
Here is my current code:
import wixData from “wix-data” ;
$w.onReady(() => {
loadLabels();
});
let lastFilterTitle;
let lastFilterLabel;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w( ‘#iTitle’ ).value, lastFilterLabel);
}, 500 );
}
export function iLabel_change(event, $w) {
filter(lastFilterTitle, $w( ‘#iLabel’ ).value);
}
function filter(title, continent) {
if (lastFilterTitle !== ‘title’ || lastFilterLabel !== ‘label’ ) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains( ‘title’ , title);
if (continent)
newFilter = newFilter.contains( ‘label’ , continent);
$w( ‘#dataset1’ ).setFilter(newFilter);
lastFilterTitle = title;
lastFilterLabel = ‘label’ ;
}
}
function loadLabels() {
wixData.query( ‘Labels’ )
.find()
.then(res => {
let options = [{ “value” : ‘’ , “label” : ‘All Labels’ }];
options.push(…res.items.map(label => {
return { “value” : label.title, “label” : label.title};
}));
$w( ‘iLabel’ ).options = options; (ERROR MESSAGE ON THIS LINE)
});
}
Any help or tips would be greatly appreciated! Thank you!