How to Return a Draggable to its origin on error
I have code as follows:
$(".assigned_draggable, .unassigned_draggable").draggable({
helper: function(){ return $(this).clone().css('border',
'1px solid red').css('background-color', '#DDD')},
opacity: .75,
start: function(e, ui){ }
});
$("#unassigned").droppable({
accept: ".assigned_draggable",
activeClass: 'droppable-active',
hoverClass: 'droppable-hover',
drop: function(ev, ui) {
ui.draggable.removeClass("assigned_draggable").addClass("unassigned_draggable");
$(this).append(ui.draggable);
campaign_id = ui.draggable.attr('id').split('_')[2];
username= ui.draggable.attr('id').split('_')[1];
$.ajax({
url: "/admin/stuff/destroy",
type: "DELETE",
data: "stuff_id=" + stuff_id + "&username=" + username,
dataType: 'script',
error: ajaxFail
});
}
});
How would I go about reverting the draggable to its original position
if the ajax request returns with an error? I am pretty new to jQuery
so maybe I am missing something.
Thanks,
Christian