2009-08-29 15 views
0

source_elementのソートを無効にしたいのですがどうすればいいですか?あなたの例ではjqueryはソート可能ではありません

function dropMembers(){ 
     $("ul.present").sortable({ 
      connectWith: 'ul', 
      containment: 'window', 
      items: 'li:not(.notSortable)' 
     }); 

     $("ul.usrlist").sortable({ 
      connectWith: 'ul', 
      dropOnEmpty: true, 
      containment: 'window', 
      update: function(event, ui) { 
       //Element ready to be dropped to new place 
        source_element = $(ui.item).attr("id"); 
        alert(source_element); 
        source_element1=source_element.split('_'); 
        alert(source_element1); 
        if(source_element[1]==GLOBAL_MY_ID){ 
         // I want to disable sorting of source_element here 
        } 
        // here is your selected item } 
      } 
//    sort: function(event, ui) { 
//    var usr_result=$("ul.usr").sortable('toArray'); 
//    //alert(ui.sortable); 
//   } 
     }); 

     $("#MAIN_USER_LIST,#USER_PRESENT_LIST").disableSelection(); 

} 

答えて

7

( 'キャンセル').sortable

$(ui.sender)ソート使用を無効にするには、私のprevousの答えのコードを持ちます。

しかし、私は、無効化運動のためのより良い開始イベントに移動するのを防止し、としてそれを無効だと思う:( 'キャンセル')

$(この).sortable。

P .:新しい質問を私のコードで作成します。

$(ui.sender).sortable('cancel')が(以前の場所に戻すようだが、並べ替えを削除するには...ソート可能

それを残し...

+0

合意した....すべて取るがない返信 – redsquare

+0

ありがとうございます –

+7

正しい機能は「キャンセル」ではなく「無効」です – Hipny

1

はこの1つ上の時間の一体を持っていた...あなたの行動を理解しないと、もう一度編集できるように)、私はこのコードを使用しました:

$('.sortable').sortable('disable'); 
$('.sortable').disableSelection('disabled'); 
$('.sortable').unbind('click'); 
$('.sortable').unbind('mousedown'); 
$('.sortable').unbind('mouseup'); 
$('.sortable').unbind('selectstart'); 

あなたの要素の指定子に変更します。私は複数のクラスでそれをやった。これらはソートルーチンによって作成された4つのイベントでした。元のコマンドで並べ替えを再開できます。

非常に便利ですか?

関連する問題