Yevgeniy Bagackiy Yevgeniy Bagackiy - 1 month ago 7
Javascript Question

Counting dropped items after removing them from droppable area

I want to count dropped items inside dropped area. Here is example. It works fine except one thing. when I start to remove items it does not count first item and only after removing first item number starts to decrease.

Function i am using to remove item:

$(".procStaff").on('click', '.closer', function(){
var item = $(this).closest('.dropClass');
var element = $("#myAccordion ul li").filter(function() {
return $(this).text() == item.text();
});

//code where i counting items
var n = $(this).closest("div.proc").find(".dropClass").length;
$(this).closest("div.proc").find("span.assigned").text("People Assigned: " + n + "");

itm.splice(item);
element.css('color','black');
item.fadeTo(200, 0, function(){ item.remove(); })
});


How can I solve this problem?

Answer

Only one Line Update in $(".projLeader").on('click', '.closer', function(){});

var n = $(this).closest("div.proc").find(".dropClass").length -1;

Live Demo Here