I need to retrieve the X & Y position of an element once its dropped, how can I implement this ?
I think I need to use the droppable callback :
$(".portletPlaceHolder").droppable({
drop: function( event, ui ) {
//...
}
});
Mate, you should read the whole page on a documentation:
All callbacks receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument 'ui'):
- ui.draggable - current draggable element, a jQuery object.
- ui.helper - current draggable helper, a jQuery object
- ui.position - current position of the draggable helper { top: , left: }
- ui.offset - current absolute position of the draggable helper { top: , left: }
droppable jQuery manual
$(".portletPlaceHolder").droppable({
drop: function (evt, ui) {
var offset = ui.offset;
console.log(offset.left + "x" + offset.top);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With