this should be a common problem but I seem to be missing something...
Lets say I have 3 combos, for the sake of example say they are for Country, State and City for a user's address info.
First I fill the country combo with all my countries from the database, the user selects one and I then fill the State combo with all the states for that country, the user selects a State and I grab all the cities, thats a pretty common scenario.
Now imagine I have a specific user who has saved their info off to the database and now wants to edit it. I retrieve their record from the DB but because the combos are dynamic I need to first fill them with the appropriate list of options, then select the correct one for the user. This rapidly becomes a really cloogey set of event listeners chained together the way I'm trying to do it. Is there a better way to tackle this that I'm missing? It seems like there 'should' be a better way to handle it.
OK well I found a more elegant solution so hopefully this will help others wondering the same thing.
When you chain combos together like in my example, you trigger the filling of one off the 'change' event of the former.
However if you programmatically set a combo to a given value it does NOT fire this change event.
This allows us to do the following (again using my initial example):
1)create a single event handler responsible to setting all 3 (or more) combos to the values for the user pulled from the database and trigger this event upon completion of #2
2)fill the individual combos all at once using the values from the DB for the user (e.g. I already know the user is from Seattle, WA, USA) so I can just fill each combo with the appropriate value 'as-if' they were being indivdually selected by the end user. This eliminates the need for chaining together event handlers to try to simulate a user's selection, much cleaner