Yevgeniy Bagackiy Yevgeniy Bagackiy - 1 year ago 66
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 + "");

item.fadeTo(200, 0, function(){ item.remove(); })

How can I solve this problem?

Answer Source

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

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

Live Demo Here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download