Reverting the draggable to it's original position on the move
Hi,
I am using a few draggables on a page and I initiate an ajax call on
'stop'. Depending on a few variables the response of the ajax call
might sometimes be 'error' and when it happens I want the draggable to
revert back to it's original position. A bit of code might clarify
things a bit..
$('#d').draggable({
stop: function() {
$.ajax({
type: "POST",
url: "post.php",
data: "data=foo",
success: function(msg){
if ( msg.indexOf('error') != -1 ){
// there has been a problem, revert the draggable to it's
original position
// just like "revert: true" but how?
}
}
});
}
});
I am aware of the existance of 'revert: true' but couldn't find a way
to incorporate it into this as all it does is revert it back and I
couldn't find a way of cancelling it.
My question is, is there a way to either:
- cancel the draggable option if the outcome of my ajax call is
'error'
- use revert: true but somehow cancel it if the outcome of the
ajax call is not 'error
Any help would be much appreciated as this is currently a huge show-
stopper :/
Thanks!