I have a drop down list as below which just shows a list of user names and their values:
@Html.DropDownListFor(m => m.SelectedUser,
Model.UsersSelectList,
"-- Select One --",
new { onChange = "users_onchange();" })
and the javascript is as below which would call an action when an item is changed:
function users_onchange() {
var selectedUserId = $('#SelectedUser').val();
if (selectedUserId == "") {
selectedUserId = 0;
}
$('#EmailAccountsContainer')
.load('/MyEntityController/EmailAccounts', { userId: selectedUserId });
}
and the EmailAccountsContainer is just a div:
<div id="EmailAccountsContainer"></div>
and the EmailAccounts Action accepts a userId and returns a partial view displaying another drop down list.
The problem is that the call to the Action only happens after the first change to the Users drop down list. If a second user is selected, no call is made to the Action.
I have turned down the caching as well on the controller:
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public class MyEntityController : Controller
How to fix this?