I’ve got an MVC3 app. I’m calling the controller via ajax from a checkbox onclick method. After the click, I’m refreshing a Telerik grid. In Chrome and Firefox, this works fine. In IE9, it works for 2 clicks, then stops. What’s up? Here’s the code:
View code:
<input type="checkbox" name="archived" onclick="javascript:ShowArchivedClicked();" id="archived" value="Archived" style="vertical-align:middle;" @{ if ((bool)Session[Const.ArchivedAttribute]) { <text>checked="checked"</text> } } /><span style="padding: 0 10px 0 0;"> Include archived records</span>
function ShowArchivedClicked() {
$.ajax({
url: '@Url.Action("SetShowArchived", "Home")',
type: "GET",
async: false,
success: function () {
var summaryGrid = $("#SummaryGrid").data("tGrid");
summaryGrid.rebind();
},
data: { showArchivedItems: $("#archived").is(":checked") }
});
}
Controller code:
[HttpGet]
public void SetShowArchived(bool showArchivedItems)
{
ShowArchivedItems = showArchivedItems;
}
private bool ShowArchivedItems
{
get
{
return Session[Const.ArchivedAttribute] == null ? false : (bool)Session[Const.ArchivedAttribute];
}
set
{
Session[Const.ArchivedAttribute] = value;
}
}
Adding this line to the ajax call did the trick: