Naftali
Naftali

Reputation: 146300

How do i keep divs in particular order?

I have this fiddle here: http://jsfiddle.net/maniator/MUa7P/

In this example a user picks a certain number of clients for an account and is able to remove the clients and add clients.

Each account can have at a max 3 clients.

How do i make it so that on either side the clients are in order of client ID always?

Thanks

Upvotes: 0

Views: 72

Answers (3)

JohnD
JohnD

Reputation: 4002

Solution that goes over the DOM to sort, this relies on everything being ordered on load.

http://jsfiddle.net/compwhizii/vHQGk/12/

Upvotes: 1

n3on
n3on

Reputation: 2090

Just use this to sort: http://jsfiddle.net/w2n9a/5/

Upvotes: 1

JaredMcAteer
JaredMcAteer

Reputation: 22536

You'll have to check the elements in the box it's adding to for it's position and then use the .insertBefore() or .insertAfter() methods

Upvotes: 0

Related Questions