|
 Franchise
 Group
 Location
 Department
<div id="rubbish" ><div style="cursor:arrow;"><img src="/dhtmlx/codebase/imgs/custom/bin.gif" width="18px" height="18px" /></div></div>
</td>
</tr>
</table>
<script language="javascript" type="text/javascript">
function _rclick(id) {
document.getElementById(“response”).innerHTML = ‘Right click:’ + id;
return false;
}
function insert_error(node) {
var div = document.createElement(“div”);
tree.deleteItem(node.getAttribute(“sid”), true);
div.innerHTML=node.firstChild.data;
document.getElementById(‘response’).appendChild(div);
return true;
}
function delete_error(node) {
tree.saveOpenStates();
tree.deleteChildItems(0);
tree.loadXML("tree_feed.php?id=0");
var div = document.createElement("div");
div.innerHTML=node.firstChild.data;
document.getElementById('response').appendChild(div);
return true;
}
function update_error(node) {
tree.saveOpenStates();
tree.deleteChildItems(0);
tree.loadXML("tree_feed.php?id=0");
var div = document.createElement("div");
div.innerHTML=node.firstChild.data;
document.getElementById('response').appendChild(div);
return true;
}
function myErrorHandler(type, desc, erData){
refreshNode(0);
}
dhtmlxError.catchError("ALL",myErrorHandler);
tree=new dhtmlXTreeObject("treeboxbox_tree", "100%", "100%", 0);
tree.setSkin('dhx_skyblue');
tree.setOnRightClickHandler(_rclick);
tree.setImagePath(“/dhtmlx/codebase/imgs/custom/”);
tree.enableDragAndDrop(true);
tree.attachEvent(“onXLE”, function() {
tree.loadOpenStates();
});
tree.attachEvent(“onBeforeDrag”, function(sID){
var nodrag=tree.getUserData(sID,‘nodrag’);
if(nodrag==‘true’) return false;
return true;
});
var sinput=document.getElementById(‘rubbish’);
tree.dragger.addDragLanding(sinput, {
_drag : function(sourceHtmlObject, dhtmlObject, targetHtmlObject){
tree.deleteItem(sourceHtmlObject.parentObject.id, true);
}
});
tree.makeDragable(“franchise”, function(drop_obj, source_id, target_on, target_before) {
drop_obj.insertNewChild(target_on, “newnode_franchise”, “NEW franchise”,0,“treefranchise.png”,“treefranchiseOpen.png”,“treefranchiseClosed.png”);
});
tree.makeDragable(“group”, function(drop_obj, source_id, target_on, target_before) {
drop_obj.insertNewChild(target_on, “newnode_group”, “NEW group”,0,“treegroup.png”,“treegroupOpen.png”,“treegroupClosed.png”);
});
tree.makeDragable(“location”, function(drop_obj, source_id, target_on, target_before) {
drop_obj.insertNewChild(target_on, “newnode_location”, “NEW location”,0,“treelocation.png”,“treelocationOpen.png”,“treelocationClosed.png”);
});
tree.makeDragable(“department”, function(drop_obj, source_id, target_on, target_before) {
drop_obj.insertNewChild(target_on, “newnode_department”, “NEW department”,0,“treedepartment.png”,“treedepartmentOpen.png”,“treedepartmentClosed.png”);
});
tree.loadXML(“tree_feed.php?id=0”);
myDataProcessor=new dataProcessor(“update.php?uid=”+(new Date()).valueOf());
myDataProcessor.defineAction(“my_insert_error”, insert_error);
myDataProcessor.defineAction(“my_delete_error”, delete_error);
myDataProcessor.defineAction(“my_update_error”, update_error);
myDataProcessor.init(tree);
<?xml version="1.0" encoding="iso-8859-1"?>Node creation successful
<?xml version="1.0" encoding="iso-8859-1"?>Node type franchise_129777389441 not allowed[/code]
I assume this is a result of dragging something onto the tree, because the id of the new element changes, it also changes the original div, as they have the same id.
|