2010-12-22 23 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有一系列的帖子可以啓動你在正確的方向。