Codex73
Codex73

Reputation: 5766

Grabbing element position at mouse release jQuery draggable

How can I grab the position of the element when the mouse was released having revert set to true.

$("#belt").draggable({
    handle: "li",
    revert: true,
    axis: "y",
    delay: 150,
    topValue: null,
    leftValue: null,
    start: function() {
        this.topValue = $(this).position().top;
        this.leftValue = $(this).position().left;               
    },
    stop: function(){
        console.log($(this).position().top);
        console.log($(this).position().left;
    }
});

Upvotes: 1

Views: 560

Answers (1)

DG3
DG3

Reputation: 5298

Update your stop function as below. The stop callback accepts two arguments, 'event' and 'ui'. By doing a console.log on both of them, you can find a lot of information.

stop: function(e,ui){
    console.log(ui.position.top);
    console.log(ui.position.left);
}

Upvotes: 1

Related Questions