Jquery可排序更新问题

时间:2011-04-11 10:24:40

标签: jquery jquery-ui-sortable

我有一个可排序的列表。用户可以在列表中添加或删除项目。他们还可以通过Jeditable编辑列表。问题是当添加一个新元素时,我用来存储列表中元素位置的方法似乎不能识别移动的新元素。

这是我到目前为止所拥有的,

<script type="text/javascript">
$(document).ready(function(){ 
$(function() {
    $("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() {
        var order = $(this).sortable("serialize") + '&action=updateRecordsListings';
        $.post("updateDB.php", order, function(theResponse){
            $("#contentRight").html(theResponse);
        });
    }
    });
});

});

$(document).ready(function(){ 
    $(".edit").editable("http://servername.com/rpc.php", { 
    submitdata : {method: "update_item"},
  indicator : "<img src='images/indicator.gif'>",
  tooltip   : "Click to edit...",
  style  : "inherit",
  onblur : "submit"
 });
 });

 function delete_item(item){ 
$.post("rpc.php", { id: item, method: "delete_item" },
 function(data) {
    $(data).hide();
    });
   }

 function add_item(){
 $.post("rpc.php",{method:"add_item"},
 function(data) {
   $("#new_items").append(data)

$("#contentLeft ul").sortable( "refresh" )

$(".edit").editable("http://servername.com/rpc.php", {  /*otherwise won't work on new element*/
    submitdata : {method: "update_item"},
    indicator : "<img src='images/indicator.gif'>",
    tooltip   : "Click to edit...",
     style  : "inherit",
    onblur : "submit"
 });
  });

   }

  </script>

当我添加项目编辑文本时,然后对返回的数组的项目进行排序

 Array
 (
     [0] => 99
     [1] => 23
     [2] => 15
     [3] => 96
     [4] => 73
     [5] => 75
 )

99是新项目。没有我放置的地方,它总是最终为0.所有其他项目正确重新排序。如果我刷新页面,它也可以完美地运行。我哪里错了?

0 个答案:

没有答案
相关问题