I have small problem.
What I want to achieve is adding sum of values from above elements to each one. For example every position have got it own time value hidden in attribute. I can get it by using jQuery
var time = $(ui.draggable).attr("time");
now we got 4 positions with time as follows:
- 432 sec
- 123 sec
- 5634 sec
- 654 sec
Now I want to sum it like this:
1. 432
2. 432+123
3. 432+123+5634
4. 432+123+5634+654
Any ideas how can I do this?
This is my code:
$(document).ready(function(){
$(".trash").sortable({
tolerance: 'touch',
receive: function (event, ui) {
ui.item.remove();
}
});
$(".DragContainer_dest").sortable({helper:'clone',
opacity: 0.5,
connectWith: '.trash',
scroll: true,
update : function () {
var order = $('.DragContainer_dest').sortable('serialize',{key:'string'});
$.post('includes/ajaxify.php',order+'&action=update');
var time = $(this).attr("time");
},
out : function () {
ui.item.remove();
}
});
$("div[class=DragContainer] .DragBox").draggable({helper:'clone'});
$(".DragContainer_dest").droppable({
accept: ".DragBox",
tolerance: "touch",
drop: function(ev, ui) {
$(this).append($(ui.draggable).clone().addClass("added"));
}
});
});
I want every element dropped or sorted in DragContainer_dest to sum values from other elements above him. Can this be done?