Hello All,
First post here. I have spent three days trying to solve this problem, which I am sure is a simple fix, but have not been able to get it to work. I am trying to build a dictionary. The search bar would allow you to search for a word while the drop-down allows you to select a first letter of words.
I have a page with a repeater linked to database “Marine Corps Slang & Acronyms” drawing from columns titled “title” and “definition”
I created a second database collection called “123” that contains the alphabet
Both are added as datasets Read Only datasets to the page as dataset1 and dataset2 respectively
The input box is “iTitle” while the drop-down is “firstLetter”
I want to be able to search by title and first letter
Right now, the dropdown list is populated but nothing occurs when selected. Previously I had this working in the editor, but not on the live site. Can anyone point me in the right direction?
import wixData from "wix-data";
$w.onReady(()=> {
wixData.query('123')
.find()
.then(res => {
let options = [{"value": '','label':'All Letters'}];
options.push(...res.items.map(firstLetter => {
return {'value':firstLetter.title,'label': firstLetter.title};
}));
$w('#firstLetter').options = options;
})
});
let lastFilterTitle;
let lastFilterLetter;
let debounceTimer;
export function iTitle_keyPress(event,$w){
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() =>{
filter($w('#iTitle').value, lastFilterLetter);
},200);
}
function filter(title,letter) {
if (lastFilterTitle !== title || lastFilterLetter !== letter) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains('title', title);
if (letter)
newFilter = newFilter.eq('firstLetter', letter)
$w('#dataset1').setFilter(newFilter);
lastFilterTitle = title;
lastFilterLetter = letter;
}
}
export function FirstLetter_change(event, $w) {
filter(lastFilterLetter, $w('#firstLetter').value);
}