Rico Drag and Drop - with dynamically created drop zones : Drag Drop « Rico « JavaScript DHTML






Rico Drag and Drop - with dynamically created drop zones

 
<!--
Apache License, Version 2.0

Revised from Rico 2.0  demo code.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title>Rico</title>

<script src="rico21/src/rico.js" type="text/javascript"></script>
<script type='text/javascript'>
Rico.loadModule('Corner','DragAndDrop');

var dropCnt=1;
Rico.onLoad( function() {
   dndMgr.registerDraggable( new Rico.Draggable('test-rico-dnd','dragme') );
   dndMgr.registerDropZone( new Rico.Dropzone('droponme') );
});

function CreateDropZone() {
  var div = document.createElement('div');
  var title = document.createElement('div');
  div.className='simpleDropPanel';
  title.className='title';
  dropCnt++;
  title.innerHTML='Drop On Me #'+dropCnt;
  div.appendChild(title);
  var id='dropzone'+dropCnt
  div.id=id;
  Element.setStyle(div, {backgroundColor:'#c6c3de'});
  document.body.appendChild(div);
  dndMgr.registerDropZone( new Rico.Dropzone(id) );
}
</script>

<style type="text/css">
body, p {
  font-family : Trebuchet MS, Arial, Helvetica, sans-serif;
}
h1 { font-size: 16pt; }

div.title {
   font-family      : Arial;
   font-size        : 10px;
   background-color : #797979;
   color            : #ffffff;
   width            : 200px;
   margin           : 1px;
}
div.box {
   font-family   : Arial;
   font-size     : 14px;
   width         : 100px;
   height        : 40px;
   text-align    : center;
   border-bottom : 1px solid #6b6b6b;
   border-right  : 1px solid #6b6b6b;
}

div.panel {
   width    : 200px;
   height   : 80px;
   padding  : 2px;
   border   : 1px solid #5b5b5b;
}

div.simpleDropPanel {
   width    : 200px;
   height   : 80px;
   padding  : 2px;
   border   : 1px solid #5b5b5b;
   margin-top: 3px;
}
</style>
</head>


<body>

<h1 style='float:left;'>Rico Drag &amp; Drop - with dynamically created drop zones</h1>

<p style='clear:both;'><button onclick='CreateDropZone()'>Create Drop Zone</button></p>

<div style="padding:5px;border:1px solid #5b5b5b;height:50px;">
  <div class="box" style="background:#f7a673" id="dragme">Drag Me</div>
</div>

<div id="droponme" class="simpleDropPanel" style="background:#ffd773">
  <div class="title">Drop On Me</div>
</div>

</body>
</html>

   
  








Related examples in the same category

1.Rico Drag and Drop with Custom Drag Class
2.Rico Drag-and-Drop: LiveGrids
3.Track drop-and-drop objects as they are moved by the user
4.Rico Simple Drag and Drop Example