Drag HTML element into List
Drag me into the List
|
</> Source
<!DOCTYPE html>
<html>
<head>
<title>Drag HTML element into List</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<link rel="stylesheet" type="text/css" href="../common/demo_style.css"/>
<style>
body {
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}
</style>
<script>
var myDataView;
function doOnLoad() {
dhtmlx.DragControl.addDrag("drag_1");
myList = new dhtmlXList({
container:"data_container1",
type:{
template:"<span class='dhx_strong'>#name#</span>#address# <br/><span class='dhx_light'>#city#</span>",
height:80
},
drag:true
});
myList.load("../common/list.xml");
myList.attachEvent("onBeforeDrop",function(context){
if (context.from == dhtmlx.DragControl){
this.add({
name:context.source.getAttribute("name"),
address:context.source.getAttribute("address"),
city:context.source.getAttribute("city")
},this.indexById(context.target||this.first()));
return false;
}
return true;
});
}
</script>
</head>
<body class="dhx_noselect" onload="doOnLoad();">
<h1>Drag HTML element into List</h1>
<table border="0" cellspacing="5" cellpadding="5">
<tr>
<td>
<div id="data_container1" class="list_demo_samples"></div>
</td>
<td>
</td>
<td>
<div id="data_container2" style="border:1px solid #c0c0c0; background-color:white;width:150px;height:397px;">
<div name="dhtmlx Team" address="5.0" city="dhtmlx" id="drag_1" style='width:150px; height:50px; color:white; background-color:navy;'>Drag me into the List</div>
</div>
</td>
</tr>
</table>
</body>
</html>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.