Hi Everyone,
I am trying to build a Search Bar with autosuggest.
I already have a repeater displaying my items with a search bar and 2 dropdown filters. This all works fine but I would like to add an autosuggest repeater showing when users type in the Search bar (input).
Ideally, that would be something as below:
Here are my issues:
-
When the repeater (for autosuggest) is Collapsed on Load, it doesn’t show up when I type something in the Search bar.
NB: when not collapsed, the repeater works fine, displaying matching items as you type. -
I want to be able to click on the item and land on my item page (dynamic page, already existing)
NB: I have tried with a table which solves this issue but issue N°1 is the same. -
Search results only match when words are in the very same order. It don’t understand as I’m using .contains.
Example: If I search “Cool Sunny Holidays”, it won’t display an item called “Cool Holidays” (title) as results but will display something called “Not Cool Sunny Holidays” as the “Cool Sunny Holidays” match.
Here is my current code (just for this feature):
import wixData from ‘wix-data’;
export function iTitle_keyPress(event) {
filter($w(“#iTitle”).value);
}
function filter(title) {
$w(“#dataset2”).setFilter(wixData.filter()
.contains(“title”, title));
$w(“#repeater1”).expand
}
IDs of Elements:
Search Bar (input) = iTitle
Dataset on page = dataset2
Repeater for autosuggest = repeater1
Hope I was clear enough.
I would be really grateful if I could get advice on this!
Many thanks!
Corentin