I have the following JS which I use to populate a dropdownlist (District) depending on which Department the user chose.
District
Department
Here the code:
Here, I'm setting the District dropdownlist as a Empty list, since I'll populate it with JS.
After that I include the following Js to Populate the District dropdownlist, first with a Select, and then with the values required depending on which Department was chose.
This works fine when I create a new Store.
The problem:
When I want to update an existing Store, I can put the Department value inside the dropdownlist, but the District dropdownlist don't populate with the value which that Store has or the other possible values in case the user wants to update this particular Store district.
I suspect that I must add some functionality to my JS, but I don't really know how.
IDEA: I suspect that I must change the 2nd part of the JavaScript to:
Thanks in advance.
EDIT: Additional info
I'm using a ViewModel since I need the properties from several models: Department, District and Store: