jQuery Sortable .toArray with ASP.NET MVC ActionResult
Posted
by Stacey
on Stack Overflow
See other posts from Stack Overflow
or by Stacey
Published on 2010-03-27T00:28:29Z
Indexed on
2010/03/27
0:33 UTC
Read the original article
Hit count: 866
jQuery
|asp.net-mvc
Third try at fixing this tonight - trying a different approach than before now.
Given a jQuery Sortable List..
<ul id="sortable1" class="connectedSortable">
<li class="ui-state-default" id="item1">Item 1</li>
<li class="ui-state-default" id="item2">Item 2</li>
<li class="ui-state-default">Item 3</li>
<li class="ui-state-default ">Item 4</li>
<li class="ui-state-default">Item 5</li>
</ul>
<ul id="sortable2" class="connectedSortable">
</ul>
And ASP.NET MVC ActionResult..
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Insert( string[] items )
{
return null;
}
Activated by JavaScript...
$("#sortable1, #sortable2").sortable({
connectWith: '.connectedSortable',
dropOnEmpty: true,
receive: function () {
var items = $(this).sortable('toArray');
alert(items);
$.ajax({
url: '/Manage/Events/Insert',
type: 'post',
data: { 'items': items }
});
}
}).disableSelection();
The 'alert' DOES show the right items. It shows 'item1, item2' etc. But my ASP.NET MVC ActionResult gets nothing. The method DOES fire, but the 'items' parameter comes in null. Any ideas?
© Stack Overflow or respective owner