lundi 23 septembre 2019

How to execute JavaScript after Dropdown Data is inserted via Ajax

I have a form that loads some of its Data dynamically via Ajax, where, apart of a lot of other stuff, I fill a dropdown list. When selecting an item it will load the corresponding data into a table.

That all works fine, but now I want to be able to, by default, load the data of the first element once the page loads.

But since the dropdown populates over Ajax, it is filled slightly after $(document).ready(), so that doesn't work.

One way it might work would be to just wait for a second or two, since then it should all be loaded, but that really isn't something I fancy doing.

Any idea how I could achieve that?

I already tried it with onloadeddata="loadData($(this)[0].selectedOptions[0].value)" on the select tag, but that doesn't seem to do anything.




Aucun commentaire:

Enregistrer un commentaire