0

I'm using jQueryUI Sortable and connectWith to allow the dragging and dropping of items between 3 unordered lists.

Each list item contains a string and a value, and has an ID assigned. When the drag-drop has been completed, I want to sum the values of each item in each list and display the total at the bottom of each list.

I could do this with an AJAX call but at the moment, I can't quite get the data I need in a format I want from the lists.

Ideally, I'd like to get an array containing the UL ID's, that in turn contain an associative array containing the ID of the list item as the key and the numerical value from within it. I'm hoping by assigning an ID to the div that contains the numerical value within each LI, I can somehow extract it.

Any advice or pointers greatly appreciated.

Thank you.

jsFiddle here

The Fiddle outputs to the console.

1 Answer 1

0

I've adjusted that fiddle and gotten it to total things up for you: http://jsfiddle.net/HNxZU/32/

It doesn't do any array stuff, but hopefully you could just grab the totals with the selected ('li.ui-state-disabled'). Let me know how you get on.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Wil, that's amazing... greatly appreciate the tips in your website too. That gets the totals without needing an AJAX call which is great. I also need to be able to save back the new lists to a database, which will require AJAX and will rely on the ID of each LI. I'll see if I can work out how to do that.
In that case, have a look at this thread stackoverflow.com/questions/2936999/… it looks like just what you need.
Thanks, I've seen that thread but it was earlier in the learning process and I didn't really understand it! Will give it a more detailed look.

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.