javascript - Logic behind drag and drop -


I am thinking "how it works" and "how should be designed and implemented" basic drag and amp ; Drop functionality

I have not implemented such functionality yet I am planning to do this for one of my projects and I have some ideas on how to implement it. I wanted to make sure that I am on the right track and that there is something for you to talk about something about people ...

We think that I have 5 elements Are listed and caught by a database;

  & lt; Div id = "1" & gt; This is the content for 1 & lt; / Div & gt; & Lt; Div id = "2" & gt; This is the content for 2 & lt; / Div & gt; & Lt; Div id = "3" & gt; This is the content for 3 & lt; / Div & gt; & Lt; Div id = "4" & gt; This is the content for 4 & lt; / Div & gt; & Lt; Div id = "5" & gt; This is the content for 5 & lt; / Div & gt;  

Since it has been drawn away from a database, we know that there is a field called "order" or "order" to order, which we are going to output. Let's also think that the "sequence" column is similar to the value divs ID: hence why: 1,2,3,4 and 5 respectively

My questions and thoughts;

If I pull div 4 and leave it between 1 and 2; What are the steps from there? Example:

1) Determine the ID of the div that is being pulled (we call it div-a )

2) ID Determination div is being inserted (and before) in this case after div-a and hence div id 1 (we call it div-b ) <

Set in the current order everything is confused ... what do i count all divs and whose un Abstract divs, I can update the DB that as? Or am I completely wrong and is there any other way?


Thanks for the answer, but I know that there are plugins and other stuff to do this, but I'm interested in the part of the argument in it. .

I believe that jquery gives you a way to catch their order based on ID?

The way I am doing this, every time an action takes place, grab the existing order, send it back to your app via AJAX. Then my app only tells about the things they were given and updated the order value of each item.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -