Is there a way to reset the position of a draggable div back to its original spot after it has been dragged using jquery ui's draggable()
? I attempted this:
$('#nav').draggable();
$('#nav').data({'x': $("#nav").css('left'), 'y': $("#nav").css('top')});
$("#c").click(function () {
$('#nav').animate({'left': parseInt($("#nav").data('x')) - 15, 'top': parseInt($("#nav").data('y')) - 14}, {duration : 500});
});
This method seems to work in older versions of Firefox but not in the latest Opera and Chrome browsers. I also tried replacing data() with attr(), without success.
Anyone know how to make this work consistently across different browsers?
Edit: You can see this code in action here: http://jsfiddle.net/MVCA6/