【发布时间】:2011-08-26 10:43:37
【问题描述】:
我有一页完整的图片,准确地说是专辑封面。我添加了代码使其可拖动,它只允许我拖动页面上的第一张图片。
这是为什么?
$(document).ready(function () {
$("#draggable").each(function () {
$(this).draggable({
revert: function (dropped) {
var dropped = dropped && dropped[0].id == "droppable";
if (!dropped);
return !dropped;
}
});
});
$("#droppable").droppable({
drop: function (event, ui) {
var AlbumToAdd = ui.draggable.data("id");
if (AlbumToAdd != '') {
// Perform the ajax post
$.post("/ShoppingCart/DragToCart", { "id": AlbumToAdd },
function (data) {
// Successful requests get here
// Update the page elements
$('#cart-total').text(data.CartTotal);
});
}
}
});
});
如果您需要查看更多代码,请发表评论
【问题讨论】:
标签: javascript jquery-ui drag-and-drop