2011-11-13 14 views
0

<ul>が2つあり、JQuery経由でドラッグ&ドロップするように設定しています。フィールドが削除された<li>にドロップされたときに、テキストを追加したいと思います。JQueryの内容を変更する際に問題が発生する

ここに私のコードです - ドロップはうまくいきますが、テキストを変更する方法がわかりません。

$(function() { 
    $("#sortable1, #sortable2").sortable({ 
     connectWith: ".connectedSortable" 
    }).disableSelection(); 
}); 

答えて

1

event callback functions([イベント]タブをクリック)のいずれかを使用して、テキストを変更できます。ここでは、updateイベント(demo)を使用しました。

$(function() { 
    $("#sortable1, #sortable2").sortable({ 
     connectWith: ".connectedSortable", 
     update: function(event, ui) { 
      // remove other messages 
      $('span.message').remove(); 
      // add message to current item 
      ui.item.append('<span class="message"> - dropped!</span>'); 
     } 
    }).disableSelection(); 
}); 
関連する問題