I am using Jquery 1.6.1 and JQuery UI sortable in an application and noticed that the JSON model binding stopped working. I have to set the “traditional” parameter of $.ajax to true in order for it to work.
$('.tracks').sortable({
update: function (event, ui) {
var order = $(this).sortable('toArray');
$.ajax({
url: '/controller/action/',
type: 'post',
traditional: true, // For model binding to work
data: { 'order': order }
});
}
});
My controller
[HttpPost]
public ActionResult Order(string[] order)
{
return new EmptyResult();
}
Apparently JQuery changed how the post variable name is formed when using an array, adding [] to the end. This change is apparently geared towards PHP and Ruby users.
Is there a simple change I can make in my current ASP.NET MVC code to make the model binding work without using the traditional way?
nope, but you could do something like:
in your master page (if you use them)