We have a view where there is a CheckBox that we are setting from a model property.
@using (Ajax.BeginForm(new AjaxOptions { HttpMethod = "get", InsertionMode = InsertionMode.Replace, UpdateTargetId = "content_list", Url = Url.Action("IndexList", "UsersAdmin", new { id = "formSearch" })))
{
.......(some code)
<div id="content_list">
@Html.CheckBoxFor(model => model.SearchAll)
</div>
<div id="content_list">
@Html.Partial("_List", Model)
</div>
}
Depending on the first load the checkbox is checked or not. This works great, no problems.
As you see the CheckBox is inside an Ajax form that refreshes the partial list that contains a list.
In the scripts we have:
$("#SearchAll").change(function() {
jQuery('#SearchAll').closest('form').submit();
});
When the CheckBox first load unchecked there is no problem. We check it and uncheck it and always the controller action is called.
The problem is when we first load the CheckBox checked (true value). In this case when we uncheck the checkbox it goes to the javascript change function but it doesn't call the controller action. When we check it back again it works good. So in this case it only works when you are checking the checkbox but not while unchecking..
We have tried many things but it seams weird...maybe somebody knows about this issue.
Thanks in advance.