YUI: DragDrop - Drag Handle
Modified version of this
DragDrop example
, for this
YDN Javascript thread
.
List 1
list 1, item 1
list 1, item 2
list 1, item 3
List 2
list 2, item 1
list 2, item 2
list 2, item 3
The Javascript
(function() { var Dom = YAHOO.util.Dom; var Event = YAHOO.util.Event; var DDM = YAHOO.util.DragDropMgr; ////////////////////////////////////////////////////////////////////////////// // example app ////////////////////////////////////////////////////////////////////////////// YAHOO.example.DDApp = { init: function() { var rows=3,cols=2,i,j; for (i=1;i
this.lastY) { this.goingUp = false; } this.lastY = y; }, onDragOver: function(e, id) { var srcEl = this.getEl(); var destEl = Dom.get(id); // We are only concerned with list items, we ignore the dragover // notifications for the list. if (destEl.nodeName.toLowerCase() == "li") { var orig_p = srcEl.parentNode; var p = destEl.parentNode; if (this.goingUp) { p.insertBefore(srcEl, destEl); // insert above } else { p.insertBefore(srcEl, destEl.nextSibling); // insert below } DDM.refreshCache(); } } }); Event.onDOMReady(YAHOO.example.DDApp.init, YAHOO.example.DDApp, true); dp.SyntaxHighlighter.HighlightAll('code'); })();
The HTML
List 1
list 1, item 1
list 1, item 2
list 1, item 3
List 2
list 2, item 1
list 2, item 2
list 2, item 3
The CSS