5

I have this code right here. I have two problems though:

  1. In the receive function, how can we get the element that just got dropped into the sortable? Not the one that was used to drop a new one, but the actual one that got dropped into the list?
  2. Since I couldn't find that, I decided to use the drop() function, but now, why is that function getting called twice?! I don't want that!

    $( "#sortable" ).droppable({
    
        activeClass: "ui-state-default",
        hoverClass: "ui-state-hover",
        drop: function( event, ui ) {
            $(ui.draggable).editable(function(value, settings) { 
                 return(value);
                 },{
                 tooltip     : "Click to edit"
              });
        }
    }).sortable({
    
        revert: true,
        receive: function(event, ui) {
            $(this).children("li").each(function(index) {
                $(this).attr("id", "content-" + index);
                });
        }
    
    });
    
Christoph
  • 50,121
  • 21
  • 99
  • 128
abisson
  • 4,365
  • 9
  • 46
  • 68
  • 1
    The actual one that got dropped into the list? Did you try `ui.helper`? – Frédéric Hamidi Jun 06 '12 at 12:56
  • It is "null" and if I change ui.item, it is the original one, not the newly one dropped. :S If I do ui.item.text('test');, it doesn't change the one in the new list. It changes the "original" one. – abisson Jun 06 '12 at 13:00
  • Frédéric Hamidi, I think you're on too something there. Consider formulating an answer out of that so we can give credit where its due. LOL – Shanimal Jun 06 '12 at 13:27
  • is `$(event.target)` the element you seek? – Mark Schultheiss Jun 06 '12 at 13:31
  • @MarkSchultheiss no. This replaces the entire sortable. I just want the new
  • that was added to this sortable. That's it.
  • – abisson Jun 06 '12 at 14:49