Is it possible to know where a jquery draggable element will revert to?
<p>I am trying to change the color of my draggable if it is reverting to a certain location. In this example, the red box changes to blue when you drag it to the green boxes on the right. I've set it so when you drag a box on top of another one, it reverts to where it was. But if the box is reverting to the container on the left, I want it to change back to red, which it does if you drag it manually there. I could also make it so if a box is in the left container it is always red, but I don't know how to do that. Any help is greatly appreciated. Thanks in advance.</p>

<p><a href="http://jsfiddle.net/watson/xE9Pe/3/" rel="nofollow">Fiddle!!!</a></p>

<p>Here is the HTML:</p>

<pre><code>&lt;div id="box"&gt;
    &lt;div class="peg"&gt;&amp;nbsp;&lt;/div&gt;
    &lt;div class="space"&gt;&amp;nbsp;&lt;/div&gt;
    &lt;div class="peg"&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;

&lt;div id="game"&gt;
    &lt;ul class="row"&gt;
        &lt;li class="hole"&gt;&amp;nbsp;&lt;/li&gt;
        &lt;li class="hole"&gt;&amp;nbsp;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
</code></pre>

<p>CSS:</p>

<pre><code>#game {
    position: absolute;
    top: 15px;
    left: 135px;
    background: wheat;
    padding: 15px;
    padding-bottom: 0;
}

.row {
    position: relative;
    margin-left: auto;
    margin-right: auto;
    height: 75px;
    margin-bottom: 15px;
    background-color: olive;
}

.hole {
    width: 75px;
    height: 75px;
    float: left;
    background-color: aqua;
    opacity: 0.3;
    margin-left: 6px;
}

#box {
    position: absolute;
    left: 15px;
    top: 15px;
    width: 90px;
    padding-bottom: 15px;
    background-color: wheat;
    padding-top: 15px;
    padding-left: 15px;
}

.peg {
    width: 75px;
    height: 75px;
    background-color: red;
    z-index: 1;
}
.space {
    height: 15px;
    width: 75px;
}

.top {
    background-color: blue;
    width: 75px;
    height: 75px;
    z-index: 1;
}
​
</code></pre>

<p>Javascript:</p>

<pre><code>$('.peg' ).draggable({
    snap: ".hole", 
    snapMode: "inner", 
    snapTolerance: 40, 
    //scope: "zappa",
    //revert: 'invalid',
    stop: function(){
        $(this).draggable('option','revert','invalid');
    },
    //helper: "clone"
});    

$('.peg').droppable({
    tolerance: 'fit'
});

$('.peg').droppable({
    greedy: true,
    tolerance: 'touch',
    drop: function(event,ui){
        ui.draggable.draggable('option','revert',true);
    }
});

$('.hole').droppable({
     drop: function(e,ui) {
          $(ui.draggable).removeClass('peg').addClass('top');
     },
     //scope: "zappa"
});

$('#box').droppable({
     drop: function(e,ui) {
          $(ui.draggable).removeClass('top').addClass('peg');
     },
     //scope: "zappa"
});
​  
</code></pre>
