I have a controller:
public virtual ActionResult CreateMultiple(int[] ids)
{
...
}
In JS, I get all selected checkbox, converting that into an array of int:
var params = [];
$("input:checkbox:checked.checkedPersons").each(function () { params.push($(this).val()); });
$("a.modalFormLink").attr("data-params", JSON.stringify( { "ids": params }));
Then, once I click that link, what I do is show a Fancybox with a view… sending the values of data-params attribute vía queryString in Fancybox href:
...
options.params = JSON.parse($(this).attr("data-params"));
var query = $.toQueryString(options.params);
...
QUESTION: Well, this is somehow working, if I have only one checkbox checked. If I have more than one, the binder fails and the parameter is null.
The content of the data-params attribute is:
{"ids":["4","6"]}
When I have just one value (and works) the content is:
{"ids":["4"]}
I’m assuming you are using ajax to make this call.
If so, try adding
to your options in the ajax call.