Dynamic Drop-down option loading issue

Hi wix team and all developers,

i have build a dynamic drop down which is working fine if i am keeping the code in the on click event only and that to with some limitations.

If i am keeping the code in

  1. on ready :- the options and values are not loading , so on clicking the drop-down, drop-down list its not opening. do i need to add some expanding code here ( infact after query its not even entering the for loop as to assign the values of options and values).

  2. on click :- (working) , in this when i am clicking 1st time then nothing happen but from 3nd click onward it works perfectly and the drop down list opens;
    ( this is a limitation that the user after opening the a page need to click three times .
    i guess my users will run away thinking the website is hanged. )

3)on render:- its not working

below code is for the 2nd option… rest of the ways not working

so if i put the code in the Selection4_Click_1 in on render or if i merger it with fill function and call the fill function from onready or onrender its not working .

Any way that when the user click 1st time only the drop down list open or anyone can help me in pointing out what i am doing wrong :slight_smile: .

Thanks for the help :slight_smile:

hey
All code that will modify or fill some controls on page with new data should always be inside the onready function. After the onReady function all controls on the page is loaded. Maybe your dropdown is actually not rendered when you try to populate it but after the 3rd click it is? Try moving the code inside the onReady.

Also make sure you populate the items in the .then function after the results have come back from the wix-data query.

How is it working when you put your loop for filling the options into the Selection4_onReady function?

Thanks @Andres , u quick support was great :slight_smile:

I figured out , all the things which need to be loaded should be within .the( ); section.
it worked perfect when put in onready

@tom it worked with on ready the mistake was i was separating the loop which should be coming along with .the() section

thanks for quick help :slight_smile:

Hi @japinder singh, can put the final code here in text form, if possible. Thx.