I have a page that contains several HTML select dropdown menus, and this requires a population of onclick elements. This collection is performed using an AJAX call in the click event listener of the select elements.
The reason for this is that performance and loading are very important, and therefore they cannot be filled when the page loads.
In addition, the design must use its own HTML select element.
I created a jsFiddle demo to show the problem. When you click on select , the elements fill up, and as a result, the width of the select increases.

However, select only displays the initial option (before the AJAX population).
The demo uses setTimeout() in 50 milliseconds to emulate the AJAX response time.
How can I get this to fill in onclick and render correctly?
Is there a way to open select when popualation response callback?
EDIT: Alternatively, is there a drop-down list of jQuery plugins that uses the browserβs native theme for styling?
What have i tried so far
- Filling
select when hovering, however a fast user can open select before loading parameters. Also, if the user has to scroll all the way down the page and through every select , this will cause many unnecessary AJAX calls. - Changing the event listener to
focus instead of click (as suggested by @AndyPerlitch ). However, this will not work if the AJAX request takes only 50 milliseconds. ( See demo ) - Changing the event listener to
mousedown has the same effect as focus
UPDATE: This is not a problem in FireFox. select opens, then loads the new elements and displays them, all in the open state.
Curt
source share