I'm starting to experiment with HTML5 Drag and Drop. Then, in the dragstart event handler we should run setData(), which receives two parameters: format and data.
function dragstart_handler(ev) {
ev.dataTransfer.setData('text/plain', 'foobar');
}
I want to drag some kind of "object" from one container into another container, inside my web application. By "object", I mean something that has multiple attributes (color, text, author, date, …).
What kind of format (or MIME Type) should I use?
text/plain?text/x-myapp-myobjtype?application/x-myapp-myobjtype?application/x-myapp.myobjtype+json?- something else?
- more than one?
How should I encode my object (the data parameter of setData())?
- Comma-separated (or any other delimiter) key=value pairs?
- Serialize the object using JSON?
- Just an id, and at the dropzone I must retrieve the full object using just the id?
- Send just a reference to the object, without even serializing anything? (not possible, the data argument must be a string)
(I realize that "How to enconde an object for Drag and Drop" could be another question here, but it is closely related to the choice of MIME Type)
Some references: