Björn C
Björn C

Reputation: 4008

Automatic drag an ".draggable" element

Is it possible to make an automatic drag (whitout mouse-drag) with jquery draggable?

I´m thinking:
Load elements from db using php.
Find element with jquery and move it to position stored in db.

JS

$(document).ready(function){
  $('#element').draggable({
    automatic move to position:
      top: 22
      left: 22                    
});

How else should i load my stored element positions?
I drag elements from one div to another.

Upvotes: 0

Views: 1984

Answers (1)

DFayet
DFayet

Reputation: 881

Define the position of your element with css.

For example:

$(document).ready(function){
    $('#element').draggable();
    $('#element').css({'top': x, 'left' : y});
});

Take a look at this example

Hope it may helps you.

Upvotes: 1

Related Questions