Problem: When code sets dropdown options, the dropdown display is not updated in preview mode.
To demonstrate:
Make a test page with a dropdown and a button
Add this code:
function setup() {
$w("#dropdown1").options = [
{ "label": "Who's on first!", "value": "first" },
{ "label": "What's on second", "value": "second" },
{ "label": "I Don't Know is on third", "value": "third" }
];
}
export function button1_click(event) {
setup();
console.log("$w('#dropdown1').options:",$w('#dropdown1').options)
}
To test:
1. Preview the page
2. Click the drop down and note the default choices
3. Click the button
4. Click the drop down and note the default choices are still there.
5. Look at the console output and notice the the dropdown options are what they were set to.
6. Publish the site and run the same test on the public site.
7. Note that the dropdown now shows the proper choices.
I have made a demo site: https://sigpoggy.wixsite.com/my-site
seconded (well third). I have experienced this issue now also.
I am running into the same issue of dropdowns not populating in Preview mode. I have seen this behavior within the past hour (CST US). It seems to be directly related to setting the .selectedIndex attribute to any number (0 to length of the options array). If I comment out setting the selectedIndex, the dropdown populates. Does not matter if values come from a hard coded array, a collection, or the results of a function. If I publish the site with the selectedIndex set, it works as expected in Live.
Yes I'm still having issues. The problem seems to be intermittent at this point. I have seen it come and go several times and can find no way to either make it always work or always fail.
Yesterday when I started developing, it worked at first. I was able to debug in preview mode for awhile since setting options was working, but hit a wall when selectedIndex failed in a light box. I decided to restart the editor since that sometimes clears up various problems that arise. But then the original problem came back.
I checked my simple demo and added code to test setting selectedIndex. Everything worked ok in the demo. I restarted the editor and it still worked.
I considered that since my page has a lot of code and elements I might be overwhelming the system. However, in prepping this reply just now, I went back to the demo and tried it again and it failed.
I have been forced to test live in a duplicate of the site to get the job finished which was about an hour ago.
Try this....
$w.onReady(()=>{setup();}) function setup() { $w("#dropdown1").options = [ { "label": "Who's on first!", "value": "first" }, { "label": "What's on second", "value": "second" }, { "label": "I Don't Know is on third", "value": "third" } ]; }