Categories | Question details Back To List | ||
dhtmlxtree onEdit does not work !!! :( Hi, I am using the dhtmlxtree professional version 1.6. I am using the tree in my project and i would like to catch the event when a modification is made on a node. I have read through the documentation and i implemented as follows: tree.attachEvent("onEdit",onNodeEdit); //call onNodeEdit function function onNodeEdit(state,id,tree,value) { switch (state) { case 0: return true; break case 1: break case 2: return true; break case 3: xmlhttprequest(); //call xmlhttprequest function break default: } } function xmlhttprequest() { var myXmlStr = tree.serializeTree(); var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } } // the following code, redirects to a java class Save which contains the method to save the serialized tree in DB xmlhttp.open("POST", "mainservlet?cl=save.Save&method=saveDhtmlxtree",true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { <!-- alert(xmlhttp.responseText) --> } } xmlhttp.setRequestHeader("Content-Type", "text/xml") xmlhttp.send(myXmlStr); } The behavior from the above code is not what i was expecting. What is supposed to do is. when ever the node is edited and not yet closed (case:3), the tree should be serialized into a var and saved to the DB. I have narrowed down the point where the error occurs and it points to the serializer. var myXmlStr = tree.serializeTree(); what could be wrong with the serializer??? Can any one point out where i am making the mistake or any other way to find when a node is edited so that the DB can be updated with the latest version of the tree. Thanks in advance choe :) Answer posted by Support on Mar 25, 2008 09:11 The problem caused by recursive calls, in moment when you call serializeTree the edit operation not fully finished yet, so - call serializeTree - tree code stop edit before serialization - call of onEdit event - call serializeTree ... infinite recursive loop... To resolve issue, just call you code a moment after edit operation case 2: return true; break case 3: window.setTimeout(xmlhttprequest,1); break |