I've had a play with droppables, and come up with the code below. When
the jigsaw piece is dropped, I append it to the canvas square (a list
item) and set the position to (0,0). However the revert isn't fired if
a piece is already in the same square on the canvas. Is there a way to
say in the drop function whether the piece was successfully placed?
==========
$(document).ready( function() {
$("div.jigsawPiece").draggable( { revert: 'invalid' } );
$("ul.jigsawCanvas li").droppable({
hoverClass: 'active',
drop: function(event, ui) {
var item = ui.draggable;
if ( $(this).find('div').length == 0 ) {
item.css('left','0');
item.css('top','0');
$(this).append(item);
}
else {
// revert?
}
}
});
});
==========
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---