Drag and Drop NotesGeneralYou may be intimidated by "drag and drop". It is really much simpler than it seems. Step OneWhat?? Imagine browsing with a browser. Now imagine a "something", "somewhere" on the screen. You want it to be "somewhere else". You click "somewhere" on the "something", hold your mouse button down, and drive the mouse to "somewhere else". Then you release the mouse button. Et Voila!! The "something" is now "somewhere else". But that is rather vague, dreamlike, perhaps. How do you code "something" into JavaScript? (ECMAScript even?) Futhermore, what does that make report 17 (Which is the worst one, but the only one the customer looks at) look like? How will the report know what you did? Where do you click on report paper to get it to update? Perhaps this is nightmare like rather than dreamlike. Step TwoLet's begin with the data. For beginning with data, that means the database. We know all about records with id, time_created, name, detail, blee, blah. So we can make records for the somethings and somewheres. Done! Well except take all of the id's from one set of numbers so no somewhere will have the same id as a something. When we send these records to the browser (Yay JSON!) we will make a DIV for each with an id that contains the record id. On the browser when we click a something, we will catch its id. When we drop the something, we will get the id of where we dropped it. We will let the back end know what we have done. Step ThreeWe do need to improve our records. We need to keep track of where our somewheres and somethings are. Image a cat, and a dog, and a marble on a square of a sidewalk on a street in a neighborhood in a city in a county in a state, in a country on a continent on a planet... Every something needs to be in a somewhere. Every somewhere (mostly) needs to be in a somwhere as well. (There should be one somewhere that does not need to be in a somewhere.) I add a field to each record called "parent" (Stolen form JavaScript ParentNode). It contains the id of the somewhere that the record belongs to. Is that it?No. How are you going to arrange all of those DIVs? (Think one DIV fo each cat and dog east of the Mississippi.) What about the 55 gallon drum of baby oil that you are selling by the ounce for huge profits? What language for the back end? |