I facing a weird problem here. I already have a simple try-out for jquery drag-n-drop and it WORKS. However, now i wan to move the code from the try-out project to the project file i working right now. Everything is the SAME, but i just cant get the drop event to be fired. It is really urgent, please help…
I included my code, just in case…
$('.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);
It seems like it works fine:
http://jsfiddle.net/DrUKa/