views:

23

answers:

2

I have four divs with custom Attributes like:

<div marker="A">A1</div>
<div marker="A">A2</div>
<div marker="B">A3</div>
<div marker="B">A4</div>

Now I would like to use jquery to make each div drag- and drop-able. Now when a user drags e.g. div A1 on div A2 (vice-verca would alos be possible), it shall compare the marker attribute and if the marker happens to be the same, I want an alert to inform the user about this.

How would I achieve that ? Can I use jquery-only or do I need a plugin for that ?

+1  A: 
Šime Vidas
I know those pages and have already read that. If you could read, then you would have had a chance to actually help answer my question.
dll32
+1  A: 

Include jquery ui sortable library...

$("div").sortable({
    opacity: 0.6,
    revert: true,
    cursor: 'move',
    update: updateList
});

function updateList() {
    var list = $("div").sortable('toArray').toString();
}

var list will contain the sorted list of the divs... you will have to figure out how to use it.

aadravid
That won't work. I found http://kuindji.com/jquery/dynamic/dynamic.html
dll32
EDIT: Might work. Thanks.
dll32
Its a working example :) You will have to figure out how to fit it with your code... give unique ids to your divs, preferably numbers so that you can get a proper feedback from the $("div").sortable('toArray').toString();
aadravid