{"id":1597,"date":"2006-07-21T01:00:55","date_gmt":"2006-07-21T05:00:55","guid":{"rendered":"http:\/\/www.markbaker.ca\/blog\/2006\/07\/21\/declarative-drag-and-drop\/"},"modified":"2008-09-03T12:45:10","modified_gmt":"2008-09-03T16:45:10","slug":"declarative-drag-and-drop","status":"publish","type":"post","link":"http:\/\/www.markbaker.ca\/blog\/2006\/07\/declarative-drag-and-drop\/","title":{"rendered":"Declarative Drag-and-drop"},"content":{"rendered":"<p>I was looking through the <a href=\"http:\/\/wiki.script.aculo.us\/scriptaculous\/show\/DragAndDrop\/\">scriptaculous drag-and-drop<\/a> pages tonight, and stumbled upon this markup\/script snippet;<\/p>\r\n\r\n<pre>\r\n&lt;div id=\"photo1\"&gt; &lt;img ... \/&gt; &lt;\/div&gt;\r\n&lt;script type=\"text\/javascript\" language=\"javascript\"&gt;\r\n new Draggable('photo1',{revert:true});\r\n&lt;\/script&gt;\r\n<\/pre>\r\n\r\n<p>Isn&#8217;t that just <em>screaming<\/em> out for <a href=\"http:\/\/duncan-cragg.org\/blog\/post\/right-way-to-do-ajax-is-declaratively\/\">declarative Javascript<\/a>?<\/p>\r\n\r\n<p>So I quickly hacked together a <a href=\"\/2006\/DragAndDrop\/decldragdrop.js\">teeny tiny script<\/a> to present the Javascript API via a declarative interface.  <a href=\"\/2006\/DragAndDrop\">See it in action for yourself<\/a> (Firefox only).  The markup for that script above would be, simply;<\/p>\r\n\r\n<pre>\r\n&lt;draggable id=\"photo1\" revert=\"true\"&gt;\r\n&lt;img src=\"...\" \/&gt;\r\n&lt;\/draggable&gt;\r\n<\/pre>\r\n\r\n<p>I&#8217;ve just got drag working right now.  Drop will be a little trickier, because I&#8217;ve got to decide whether I want to setup something like an &#8220;onDrop&#8221; handler (pro: powerful, con: powerful), or whether I can define some canned droppable types, like a shopping cart, or a file uploader, etc..  Perhaps both?<\/p>","protected":false},"excerpt":{"rendered":"I was looking through the scriptaculous drag-and-drop pages tonight, and stumbled upon this markup\/script snippet; &lt;div id=&#8221;photo1&#8243;&gt; &lt;img &#8230; \/&gt; &lt;\/div&gt; &lt;script type=&#8221;text\/javascript&#8221; language=&#8221;javascript&#8221;&gt; new Draggable(&#8216;photo1&#8242;,{revert:true}); &lt;\/script&gt; Isn&#8217;t that just screaming out for declarative Javascript? So I quickly hacked together a teeny tiny script to present the Javascript API via a declarative interface. See it [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3],"class_list":["post-1597","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-ajax"],"_links":{"self":[{"href":"http:\/\/www.markbaker.ca\/blog\/wp-json\/wp\/v2\/posts\/1597","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.markbaker.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.markbaker.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.markbaker.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.markbaker.ca\/blog\/wp-json\/wp\/v2\/comments?post=1597"}],"version-history":[{"count":0,"href":"http:\/\/www.markbaker.ca\/blog\/wp-json\/wp\/v2\/posts\/1597\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.markbaker.ca\/blog\/wp-json\/wp\/v2\/media?parent=1597"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.markbaker.ca\/blog\/wp-json\/wp\/v2\/categories?post=1597"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.markbaker.ca\/blog\/wp-json\/wp\/v2\/tags?post=1597"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}