我有一组可以拖动的元素(如果需要,可以拖放),当用户停止拖动操作时,如果用户取消,我需要出现一个表单(通过拖动:停止或放下)来更新移动的对象模态表单,我希望该项目“恢复”到用户从中拖动它的原始位置。所以似乎有几个选择:
对我来说,这是众所周知的“鸡和蛋”场景,我相信你会很快告诉我根本不是这样,但它是这样的:拖放成功,或者放下并“做某事”而使用revert:invalid
?
$("#draggable").draggable({
//revert: true,
revert: "invalid",//only works with drop
cursor: "hand" ,
grid: [ 44,0 ],
axis: "x",
cursor: "move",
stop: function(ev, ui){
//Do Something here??
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"Yep": function() {
$( this ).dialog( "close" );
},
"Nope": function() {
$( this ).dialog( "close" );
// ...or Do something here?
}
}
});
}
});