2010-12-22 50 views
2

我构建的jQuery UI可排序以使用序列化和ASP.NET Web服务在数据库中存储顺序。使用jQuery UI的ASP.NET Web服务示例可排序的序列化方法

我知道如何在php中做到这一点,但我不知道如何在ASP.NET中做到这一点......我试着用Google搜索一点点成功。

$('#mylist').sortable({ 
     handle: ".handle", 
     axis: "y", 
     update: function() { 
      var order = $(this).sortable('serialize'); 
      alert(order); 
     } 
    }); 

给我查询字符串item[]=2&item[]=1&item[]=3&item[]=4

我需要传递到Web服务,并存储新订单到数据库中。

回答

2

我认为是执行以下

$('#mylist').sortable({ 
    handle: ".handle", 
    axis: "y", 
    update: function() { 
     var order = $(this).sortable('toArray'); 
    } 
}); 

代码这给ID的数组中出现的顺序。现在当你保存并获得这个数组时,请执行此操作。 // psedocode

for each id in the arrayList 
GetElementByid(id); attach to parent UL 

最后,如果你看到,该列表将被安排为先前的状态

1

Dave Ward有一系列的帖子可以启动你在正确的方向。