November 2011
Intermediate to advanced
384 pages
13h 23m
English
To begin supporting HTML5 drag and drop in your website, you must first instruct the web browser which HTML objects are actually draggable. Fortunately, this is very easy with the advent of a new global attribute appropriately named draggable. To activate this, set its attribute value to true:
<element draggable='true'>...</element>
All elements identified as draggable will start firing off dragstart and dragend events. Listening for these will allow your code to launch when the user begins and completes the drag-and-drop process, relative to the element being dragged.
Using jQuery’s selectors and its each() method, registration for this event is very easy to do:
<script type='text/javascript'> $('[draggable=true]').each(function(){ ...Read now
Unlock full access