drummer392
drummer392

Reputation: 473

Drag 'N Drop Divs into other Divs

I am wanting to create draggable content divs that can be sorted into other divs on a page. The problem is the Divs are user generated, so I won't know what the divs are called or how many divs there will be.

Basically, how can I sort divs across multiple divs and save that information to the database? I know how to sort information inside one div, but not across multiple divs where I don't know how many or what the names will be.

Upvotes: 0

Views: 469

Answers (2)

Evan
Evan

Reputation: 6115

well your question is fairly vague, so i'll answer fairly vaguely, should be in the right direction tho

what I would try to do is use Jquery UI, and when you initialize the draggable, in your option function for dragstop, inspect the parent element of the div and make an ajax call with the data you need to send to the server and have on the parent divs a data attribute -> data_yourData="whateverIam"

dragstop(function(){
    ajax call -> send this $(this).parent().data("whateverDataYouNeedToSendToTheServer");
)};

obviously this is pseudocode-ish

Upvotes: 0

Manuel van Rijn
Manuel van Rijn

Reputation: 10305

you really should take a look at jQuery UI

  1. Sortable
  2. Dragable
  3. Dropable

Upvotes: 2

Related Questions