Why is my UI / Draggable 'create' event dispatched by an empty "ui" object?

I have an image inside a div. I want this image to be dragged into a div, and I want to keep the image coordinates. Using the "stop" event on Draggable works well for this and does exactly what I want. I also want the same code to be fired in the "create" event. However, when using the same code in the create event, it seems that the passed ui object is empty:

$(document).ready(function() {
    $('#imageitem').draggable({
        containment: "parent",
        stop: function(event, ui) {
            console.log(ui);  // results in full object being printed 
        },
        create: function(event, ui) {
            console.log(ui);  // results in empty object being printed: Object { }
        },
    });
});

The docs for UI / Draggable show that the create callback should receive a ui object:

$( ".selector" ).draggable({
   create: function(event, ui) { ... }
});

ui.offset, - . , "ui" DOM , . ui.offset "" ?

, jQuery, - .

+3
1

, , , offset . . , - ?

-, ( , , , ui ), , .offset() . .. create , , :

console.log($("#idOfDraggableElement").offset());

: jsfiddle, , .

+1

All Articles