views:

85

answers:

2

Hi. I'm new to jQuery and I need help with my little project. I'm making drag&drop list to move movie clips and count their times when dropped to destination target... and this is working OK... But main problem is that I want to sort positions in destination div. I don't know how to make all elements time update with sortable->change event. I want "time" to appear after each div as my code show. This is a time when clip should start. I believe that I have to clear all attributes with $("b").remove(); (I only want to update time) and then use $.each(); function to re-count all elements ant then append "time" to them. Can anyone help me with that?

Here is my code: http://lukasz.webh.pl/test.html

To clarify what I want to achieve: For example lets say It'll be internet radio station program schedule. On the left hand we have available programs. We are choosing program witch we want to add to schedule and we're dragging it to destination DIV. Then script is collecting its time and show when it should start. So every element (time) should be sum op previous elements. And theoretically it work until we want to change program position...

+1  A: 

try replacing this line

$(this).append("<b>" + czas + " </b>");

with

var timefield = $(this).find("b");
if(timefield.length){
  timefield.html(czas);
}else{
  $(this).append("<b>" + czas + " </b>");
}
pǝlɐɥʞ
Thank You for reply.Unfortunately I want "time" to appear after each div as my code show. This is a time when clip should start.I only want to update "time" attribute when sorting because if we change clip position it start time will also change.
PsychoX
A: 

Assuming you want to have the same time for all elements why not issue:

$('b').html(newTime);

Then you can update all at once.

David Robbins
Thanks for reply. Unfortunately as I commented previous post I need sum of previous clips times to appear after each position. his is a time when clip should start.
PsychoX