Hello, I have never used the Wix Code much, but that’s going to change soon, after I figure out what’s wrong here. When I try to load the code on one of my pages, with no issues from what I see, it says “loading the code for this site/[page name]” and stays that way permanently, and the code won’t work. I have no idea how to debug it either, so any help would be great!
So if you enter some string in the text input field searchField nothing happens? You could also take away the first or because it is the same as the first .contains condition. Then I wonder what the field #iTitle is, are you sure that is a field and that you don’t want to modify that to $w(“#searchField”).value ?
Hi,
Have you tried refreshing the table after setting the rows to the table?
Tal.
(Sorry for the late reply)
Andreas Kviby: Yes, nothing happens when I enter data into the search field. #iTitle is just what I call the #searchField. I removed the first .or, while it doesn’t fix the issues, it does clear up some text so thank you for that.
Tal: How do you refresh the table after setting the rows?
There’s a link to the documentation with an example on my previous reply
Tal: I added the refresh code, with no errors, but the code still doesn’t do anything to the page, still saying
Loading the code for the site. To debug this code, open masterPage.js in Developer Tools.
Loading the code for the (PAGE). To debug this code, open dboec.js in Developer Tools.
import wixData from 'wix-data';
export function searchField_keyPress() {
wixData.query('Coaster_Inversions')
.contains('Title', $w('#iTitle').value)
.or(wixData.query('Coaster_Inversions').contains('Description', $w('#iTitle').value))
.find()
.then(res => {
$w('#table1').rows = res.items;
});
$w("#table1").refresh();
}
Hi,
Try to refresh the table after assigning the table rows:
import wixData from 'wix-data';
export function searchField_keyPress() {
wixData.query('Coaster_Inversions')
.contains('Title', $w('#iTitle').value)
.or(wixData.query('Coaster_Inversions')
.contains('Description', $w('#iTitle').value))
.find()
.then(res => {
$w('#table1').rows = res.items;
$w("#table1").refresh();
});
}
Tal: Really sorry about the really late reply, but I tried the new code and it still doesn’t do what it’s supposed to. The code has no errors and responds the same as before. Do you have any other ideas? Thank you for helping.
Maybe you don’t get results when querying the second query. Have you tired console.log the res variable?
Tal: I am unsure how to do that, can you please explain?
Thank you so much for helping!
.then(res => {
console.log(res.items); // This will console log your items so you can see if you get hits
Andreas Kviby: Sorry for the even later reply, but the period “.” is getting the error “Parsing error: Unexpected Token”
Thanks for the help.