So I have been trying for a while to get the items from a database loaded into a drop down selector but I want to do it with wix rendering. I have no problem doing it without rendering, but I just want to try and improve performance.
The issue I am having is that it loads the information and event puts the titles into the drop down but when you click the drop down, the drop down value selected is always the default. I have it logging what the title and value is of the option selected but it shows the title and value of the default one even though the title is not the default.
Here is my code:
import wixData from ‘wix-data’;
import wixWindow from ‘wix-window’;
import wixLocation from ‘wix-location’;
//load countries data
let countries;
if (wixWindow.rendering.renderCycle === 1) {
countries = wixData.query(“Countries”).find();
}
//page ready
$w.onReady( function () {
if (wixWindow.rendering.renderCycle === 1) {
$w(“#text1”).text = "starting " + wixWindow.rendering.renderCycle;
**return** countries.then(results => {
let options = [{
"value": '',
"label": 'All Countries'
}];
options.push(...results.items.map(country => {
**return** {
"value": country.location,
"label": country.location
};
})); //end push
$w("#countries").options = options;
});//end countries.then()
}//end-if
});//end onReady
I thought maybe having the two return statements was screwing it up so I tried it with a for each and a for loop but it did the same thing. Even after testing it with ?forceSsr=true, nothing different happened.
It worked when I used a table but doesn’t want to work with drop down selector.
See how it works with the labels
But see what happens when I click, it prints the drop down item to the console and it is empty.
The empty link error is from the database. My client put “not available” for urls he did not have. Could that possibly be causing it mess up the rendering process? I have this under page code… does it only work on the site code?
I am not sure if I am missing something or not but if you see something wrong or have any tips, please let me know! It will be greatly appreciated. You can check it our for yourself here: https://www.sylvainpasliermusic.com/list-of-handpan-makers