2011-07-12 59 views
0

可能重複領取方法:
How call first receive method in sortable如何調用首先在排序

我使用jQuery排序2名conected名單。

<ul id="sortable1"><li></li>....</ul> 
<ul id="sortable2"><li></li>....</ul> 

這是我用於第一次排序的代碼。 (在第二我只運行recive,因爲我不需要更新)

$("ul#sortable1").sortable({ 
placeholder: "ui-state-highlight", 
connectWith: ".connectedSortable", 
dropOnEmpty: true,     
receive : function (event, ui) 
{   

    $.getJSON(url, data, function(data){ 
      // add to database   
    }) 
}, 
update : function() { 
    $.getJSON(url, data, function(data){ 
      // change elements positions    
    }) 
}, 

})。disableSelection();

問題是,首先運行更新,我改變位置然後接收方法,我添加到數據庫元素。如何使接收方法首先運行?

如果我將運行第一個接收方法我可以取消更新,所以我只會做一個ajax調用?

因此,像這樣

$("ul#sortable1").sortable({ 
placeholder: "ui-state-highlight", 
connectWith: ".connectedSortable", 
dropOnEmpty: true,     
receive : function (event, ui) 
{   
    // prevent run update method 
    $.getJSON(url, data, function(data){ 
      // add to database 
      // change elements positions   
    }) 
}, 
update : function() { 
    $.getJSON(url, data, function(data){ 
      // change elements positions    
    }) 
}, 

})disableSelection()。

接收方法首先運行這是我的錯誤。

回答

0

這是我的錯誤jQuery默認排序第一個接收方法。