jquery 拖拽排序

    $(function () {
             $("#sortable1, #sortable2").sortable({
                 connectWith:".connectedSortable",
                 stop:function () {
                     var array_l = [];
                     var array_r = []
                     $(".left_hand").children(".tableform").each(function () {
                         array_l.push(this.id);
                     });
                     $(".right_hand").children(".tableform").each(function () {
                         array_r.push(this.id);
                     });
                     var p = array_l.join("-") + "/" + array_r.join("-")
                     localStorage.position = p
                     $(".text").html(p)
                 }
 
             });
 
             //排序后保存有两种方法,一是cookie,本地存储,二是ajax到数据库配置文件。 
             if (localStorage.position) {
                 var pp = localStorage.position
                 h = pp.split("/")
                 var left_ary = h[0].split("-")
                 var right_arry = h[1].split("-")
                 $.each(left_ary, function (key, value) {
                     obj = "#" + value
                     $(obj).remove().appendTo($(".left_hand"))
                 })
                 $.each(right_arry, function (key, value) {
                     obj = "#" + value
                     $(obj).remove().appendTo($(".right_hand"))
                 })
             }
 
         });

demon:

 

posted @ 2012-12-10 02:02  break_happy  Views(387)  Comments(0)    收藏  举报