【发布时间】:2014-09-15 05:29:29
【问题描述】:
我的代码如下。
function editState()
{
var b = confirm("Are you sure?");
$( ".usMainDef" ).draggable({
appendTo: "body",
revert:true,
stack: ".usMainDef"
});
$('.inproUS').droppable(
{
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: ".usMainDef",
drop: function( event, ui ) {
if (!b) {
} else {
id= $(ui.draggable).prop('id');
var colid=$(event.target).attr('id');
var newid=parseInt(id);
$( "<div id='"+id+"' class='box usMainInp' ></div>" ).html( ui.draggable.html() ).appendTo( this).draggable( {cursor: 'move', revert:'invalid' });
$.ajax({
type: "POST",
url: "index.php?r=workspace/changeState",
// The key needs to match your method's input parameter (case-sensitive).
data: {
uState:colid,
uID:newid
},
dataType: "json",
success: function(data){
},
failure: function(errMsg) {
alert(errMsg);
}
});
}
}
});
}
当我拖动具有“usMainDef”类的元素时,它会提示确认。如果我点击“取消”,我想回到之前的位置。如果我点击“确定”,它应该发送 ajax 请求。后面的部分正在工作。我的问题是当我单击“取消”元素时不会移动到它的起点。我该怎么做?
【问题讨论】:
标签: jquery ajax draggable droppable confirmation