我正在使用 jquery 拖放功能。现在我只想删除图像地图区域。如果光标落在图像地图之外,则可拖动区域应返回 false。请任何人帮助我。
以下是我的编码
$j(函数 () {
$j("#draggable").draggable({
revert: function (dropped) {
var $jdraggable = $j(this),
hasBeenDroppedBefore = $jdraggable.data('hasBeenDropped'),
wasJustDropped = dropped && dropped[0].id == 'treearea';
alert(wasJustDropped);
if (wasJustDropped) {
//centering with css
centerPopup();
//load popup
loadsharePopup();
return false;
} else {
if (hasBeenDroppedBefore) {
return true;
} else {
return true;
}
}
}
});
$j("img#tree").droppable({
activeClass: 'ui-state-hover',
hoverClass: 'ui-state-active',
drop: function (event, ui) {
//var Stoppos = $j(this).position();
//alert("STOP: \nLeft: "+ Stoppos.left + "\nTop: " + Stoppos.top);
var newPosX = ui.offset.left - $j(this).offset().left;
var newPosY = ui.offset.top - $j(this).offset().top;
// alert($j(this).offset().left);
$j("#txtPosX").val(newPosX);
$j("#txtPosY").val(newPosY);
//alert("STOP: \nLeft: "+ newPosX + "\nTop: " + newPosY);
$j(this).addClass('ui-state-highlight').find('p').html('Dropped!');
$j(ui.draggable).data('hasBeenDropped', true);
}
});
});