I’d like to achieve the following effect using ASP.NET MVC and JQuery.
I’ve got a drop down list displaying a list of Countries. I want to make it so that when I change the value of the country, a new drop down list appears below it, showing a list of companies whose country of origin is the particular selected company. The thing is that I do not want to rely too much on controller actions because I’m using it in a Template Helper which is a “headless” view. Can I bind it somehow?
I would suggest you creating an action which will return a JSON representation of all the companies for a selected country:
Then assuming you already have a dropdown bound to the countries:
you could register for the
onchangeevent and when this event occurs perform an AJAX call to theListaction of theCompaniescontroller and get the associated companies: