2011-08-08 10 views
0

コードは完璧に動作します。ソート可能なアイテムの順序を追跡し、アイテムがポジションを変更するたびに変数に格納することは可能ですか?jqueryでソート可能な項目の並びを取得

$('div.divContent ul').sortable({ 

    'remove': function(event, ui) { 

    }, 
    'create': function(event, ui) { 
     if ($(".widget-placeholder ui-droppable")); { 

     } 

    }, 
    'placeholder': 'div.divContent ul', 
    'cursor': 'crosshair', 
    'connectWith': 'div.divContent ul', 
    'start': function(event, ui) { 

     $(".widget-placeholder ui-droppable").disableSelection(); 
     $(ui.droppable).remove(); 

    }, 

    'stop': function(event, ui) { 
     if ($('div.divContent ul').length)) { 


     } 
    }, 
    'cancel': function(event, ui) { 


    }, 
    'sort': function(event, ui) { 

     if ($('ul li').length) { 

     } 
    } 
}); 
+0

@カルムは私の質問を編集してくれてありがとうございます。 –

+0

update()メソッドで.sortable( 'serialize')関数を使用しようとしましたか(あなたの李さんは "order_ "のようなIDを持つ必要があります)?より一般的なスコープで定義された変数にその変数を保存できるはずです。 – Thorsten

+0

@Thorstenは、 '.sortable( 'serialize')'についてのサンプルコードやリンクを持っているかもしれません。plz share.Thanksたくさんあります。 –

答えて

1

あなたは、現在の項目の位置を取得するために

$('li').index(ui.item); 

を使用することができます。これで使用するイベントを選択する必要があります。

+0

ありがとうございました。あなたのans.'var modules = $(this).parent( 'ul')の中にsolunがあります。find( 'li'); アラート(modules.length); $ .each(modules、function(index、item){ アラート($(this).html()+ " - " + $(this).index()); });将来のために同じ問題を探している人がいれば解決策です。 –

+1

問題ありませんシュリー:) – Calum

関連する問題