Title: How to use loadData for a tree with data contained in a variabble Post by: forum6691 on April 05, 2014, 10:05:54 AM I have a tree named "treev"
When I use this code J('#treev').tree('loadData', [{"id":1,"text":"node1","state":"open"}]); all is ok. When I use a variable $var which contains the string "[{"id":1,"text":"node1","state":"open"}]" and I Use this code J('#treev').tree('loadData',$var); I get an recursive error too much recursion http://localhost/Club-Regate/regate/easyui/jquery.min.js Line 4 And a lot of "Undefined" displayed in the tree ! I don't understand this problem. My variable contains the same string than this I put by hand. Where is the problem ? Thanks for your help Title: Re: How to use loadData for a tree with data contained in a variabble Post by: stworthy on April 05, 2014, 06:44:08 PM The data to be loaded into tree must be an array not string.
Code: var data = [{"id":1,"text":"node1","state":"open"}]; Title: Re: How to use loadData for a tree with data contained in a variabble Post by: forum6691 on April 05, 2014, 11:10:47 PM Ok, I understand the needs of an array, but when I put an array, I obtain nothing to the screen
Look at the code: I have an ajx method from jquery to ask the server Code: J.ajax({ My server give me a jsonresponse. With firebug the data contains: data Object { id=1, text="node1", state="closed"} and the jqXHR.responseText contains: responseText "{"id":1,"text":"node1","state":"closed"}" If I use Code: J('#treev').tree('loadData', data); If I use Code: var donnee= jqXHR.responseText; Title: Re: How to use loadData for a tree with data contained in a variabble Post by: stworthy on April 06, 2014, 07:17:18 AM My server give me a jsonresponse. With firebug the data contains: data Object { id=1, text="node1", state="closed"} and the jqXHR.responseText contains: responseText "{"id":1,"text":"node1","state":"closed"}" You are returning un-array data. Please check your code carefully. The example below works fine. http://jsfiddle.net/j2w6g/ Title: Re: How to use loadData for a tree with data contained in a variabble Post by: forum6691 on April 06, 2014, 08:53:11 AM I have found a solution. I must add bracket around data
Code: J('#treev').tree('loadData', [data]); With this bracket, it's OK. Strange ? |