I had this code set up and it ran for some time and when I checked the website online, the dropdown stopped working. I went back to the editor to find out why. I’m rereading the code and I can’t seem to find why…Is anyone else having these issues where the code isn’t working after a period of time that was working?
import wixData from "wix-data";
export function HSSchedule_change(event) {
//Add your code for this event here:
$w('#box3434').show();
$w('#imageX888').hide();
}
// Runs a query on the "sports" collection
wixData.query("HS_Sports_Schedule")
// Query the collection for any items whose "sports" field contains
// the value the user selected in the dropdown
.contains("sports", $w("#HSSchedule").value)
.find() // Run the query
.then(res => {
// Set the table data to be the results of the query
$w("#repeater2");
});
Line 13 is the issue…per the console log.
.contains("sports", $w("#HSSchedule").value)
Anybody can see the log od your console.
Perhaps you should show a screenshot?
Is this you whole code?
If so, it normaly never could work like this.
Where is your → onReady()-command, right after —>
import wixData from"wix-data";
???
Something like this…
import wixData from "wix-data";
$w.onReady(async()=>{
// Runs a query on the "sports" collection
wixData.query("HS_Sports_Schedule")
// Query the collection for any items whose "sports" field contains
// the value the user selected in the dropdown
.contains("sports", $w("#HSSchedule").value)
.find() // Run the query
.then(res => {console.log(res.items)
// Set the repeater data to be the results of the query.
$w("#myRepeaterIDhere").data = res.items
// Set the table data to be the results of the query.
$w("#myTableIDhere").rows = res.items
});
$w('#HSSchedule').onChange(()=>{
//Add your code for this event here:
$w('#box3434').show();
$w('#imageX888').hide();
})
});
@russian-dima
import wixData from "wix-data";
$w.onReady(async() => {
});
// Runs a query on the "sports" collection
wixData.query("HS_Sports_Schedule")
// Query the collection for any items whose "sports" field contains
// the value the user selected in the dropdown
.contains("sports", $w("#HSSchedule").value) //<----Line 10//
.find() // Run the query
.then(res => {console.log(res.items)
// Set the table data to be the results of the query
$w("#repeater2").data = res.items
});
Error says:
Error: The element selector function (usually $w) cannot be used before the page is ready - Line 10
I don’t have a table. Just a repeater. Editor X version.
import wixData from "wix-data";
$w.onReady(async() => {
// Runs a query on the "sports" collection
wixData.query("HS_Sports_Schedule")
// Query the collection for any items whose "sports" field contains
// the value the user selected in the dropdown
.contains("sports", $w("#HSSchedule").value) //<----Line 10//
.find() // Run the query
.then(res => {console.log(res.items)
// Set the table data to be the results of the query
$w("#repeater2").data = res.items
});
});
If you don’t put them INSIDE the onReady… so it won’t trigger when the page is loaded…
Again: INSIDE the $w . onReady function! INSIDE the {}
@certified-code Yes, missed that one. Thanks.
@russian-dima no, still working on it.
@jfriede Ok, if you are still working on it, then it is a good sign, that you do not give-up quickly. Then you surely will be able to solve it on your own.
If not, you know where to ask your question.
@russian-dima I finally got it to work again! I was on a spring break and this morning, I got back into it and all that jazz works! Sometimes I need a break, I guess. Thank you for checking on me! 