Hi there,
I’m trying to create search bar with the code below by the Wix video on youtube but for some reason, it’s not working. If you can see the problem please let me know.
import wixData from "wix-data";
export function iTitle_keyPress(event, $w) {
wixData.query('Novinky');
console.log($w('#iTitle').value);
filter($w('#iTitle').value);
}
function filter(title) {
$w('dataset1').setFilter(wixData.filter().contains('Title', title);
}
Hi Jakub,
The code in below may give you some helps,
import wixData from 'wix-data'
//...
export function iTitle_keyPress() {
var searchValue = $w("#iTitle").value;
wixData.query("Novinky").eq("propertyInDataBase", searchValue).find().then( (Res)=>{
// if there are items do...
if ( Res.items.length > 0 ) {
// Table or Repeater items equal to Res.items...
//For example,
$w("#ThereAreNoItemsText").collapse();
$w("#repeater").expand();
$w("#repeater").data = Res.items;
} else {
// if there are no items do....
//For example,
$w("#repeater").collapse();
$w("#ThereAreNoItemsText").expand();
}
} );
}
Hi Heson,
Thank you for your response. I used your code but I still doing something wrong. Now when I write something to search bar it will only collapse. I will focus on it for a few days and then I will let you know about my progress.
when looking at the - console.log($w(’ #iTitle ').value);
does it print what you expect?
when using the code in the example, specifically ’ propertyInDataBase’ :
The field name for ‘Title’ is most probably ‘title’, all fields start with a lower case letter.
Try wixData.query(“Novinky”).eq("title", searchValue) …
Hi Ido,
that’s not helping.
I did create Wix profile with 1 site only where I’m trying figure this out.
If I write here Login email and password can you check it out if everything is set well?
This profile was created only for this purpose so I can share it with you guys if you don’t mind and if you would be so nice.