0
我在這裏面臨一個奇怪的問題。我已經有了一個簡單的jquery drag-n-drop試用版,它很有用。但是,現在我想將代碼從試用項目移到我現在正在工作的項目文件中。一切都是相同的,但我不能讓丟棄事件被解僱。這實在是急了,請幫助... 我包括我的代碼,以防萬一......jQuery Drop事件不起作用
$('.image').draggable({
cursor: 'move'
});
// Put img resizable is to have the ghost
$('.image img').resizable({
ghost: true,
stop: function (event, ui) {
var eid = $(this).parent().attr('id');
alert(eid);
var wid = $(this).width();
alert(wid);
var hei = $(this).height();
alert(hei);
updateSize(eid, wid, hei);
}
});
// Variable to hold drop options
var options = {};
// Once image re-drop, update its position
options.drop = function (event, ui) {
// Check image id to check whether image exist or not
if (ui.draggable.attr('id').match(/_(\d+)$/) != null) {
var element = ui.draggable;
updatePosition(element);
}
else {
// Store the clone position
var leftPosition = ui.offset.left;
var topPosition = ui.offset.top;
alert('Left: ' + leftPosition + ' Top: ' + topPosition);
// Variable to generate new image id
var counter = new Date().valueOf();
// Create the clone
//var element = ui.draggable.clone();
// Assign new id for clone element
var oldID = ui.draggable.attr('id');
alert('old id ' + oldID);
ui.draggable.attr('id', (oldID + '_' + counter));
// Call CreateContainer
createContainer(ui.draggable, oldID, topPosition, leftPosition);
}
};
$('#rightframe').droppable(options);
有包括你的jquery.js和jquery-ui.js – Rafay
嗨,我包括: – shennyL