0

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...

2
  • So do you only want a single time to appear, at the end of your list? Commented Jan 5, 2010 at 13:18
  • No. I want time to appear after each entry as a sum o previous times (as in my code when You drop element to right div). But I want also to sort elements and I don't know how to update every element time value. For example we have two clips (or radio programs). First is two minutes long and second five. In this order second one will start at 08:02 (starting from 08:00). But when we swap them the second one will start at 08:05. Commented Jan 5, 2010 at 16:42

2 Answers 2

1

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>");
}
Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

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

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

Then you can update all at once.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.