2016-06-15 93 views

回答

1

沒有測試這一點,但在這裏我們去:

// list with one entry for each item 
var todo_list = { 
    id1: false, 
    id2: false, 
    id3: false 
}; 

// total number of items to be dropped by the user 
var remaining = 3; 

$("#droppable").droppable({ 
    drop: function(event, ui) { 
     if (todo_list[this.id] === false) { 
      todo_list[this.id] = true; 
      remaining--; 

      if (remaining === 0) { 
       do_something(); 
      } 
     } 
    } 
}); 

裏面的drop回調,你應該能夠通過使用this.id訪問放置項目的id

+1

謝謝!這真的幫助我了! – AndrewLeonardi