Ext: how can I use data from an ajax request to modify an existing Javascript element? -
for days i've been searching explanation on how right. tried find decent tutorial either js or ajax, one's found rather basic , didn't go deep enough. when want solve problem python, go python.org, php use php.net, haven't found decent ressource js , ajax yet. tips appreciated.
so i'll try explain did. have rather simple page, has div on left , div on right. within left one, tree rendered, representing registry, within right one, values displayed , edited.
the tree stored in global variable. have read warnings using global variables, think it's justified in case. whenever page accessed, tree displayed.
var tree; ... function inittree(treerootconfig) { return new ext.tree.treepanel({ renderto : 'tree' ,width : 500 ,height : 498 ,autoscroll : true ,resizable : true ,usearrows : false ,animate : true ,loader : { dataurl : urls.urlloadtree, listeners: { beforeload : function(treeloader, node) {} } },listeners: { click : function(node, e) { valuegrid.load(node.id); } ,contextmenu : function(node, e) { cmpath.node = node; cmpath.showat(e.getxy()); }, },root : treerootconfig }); }
there textfield holds textual represantation of path, tree displaying.
function inittextfieldpath() { return new ext.form.textfield({ fieldclass : 'textfieldpath', applyto : 'path', enablekeyevents: 'true', listeners : { change : function() { refreshtree(); } }, }); }
every node "folder" in path. when new node accessed, value of textfield modified accordingly. working fine. when new path entered textfield, want tree reloaded show nodes. path parsed , and use ajax nodes out of database. works point, string represantation of node, encode via json , try set node new root tree.
function refreshtree() { ext.ajax.request({ url : urls.directaccess ,scope : tree ,params : { path: textfieldpath.getvalue() } ,success: function(response, opts) { alert(response.responsetext); tree.setrootnode(ext.util.json.decode(response.responsetext)); } ,failure: function(response, opts) { noconnection(response); } }); }
as can imagine, alert in there testing purposes. when server request done, displays string represantation of node fetched database. setting node tree cannot done.
the ext license have ext 3.4.0.
the problem else entirely. thought not possible communicate variable declared outside of ajax statement within ajax statement. turns out had '[' , ']' much. target expecting '' gave array 1 member '[]'. kinda weird though, because in other cases ext accept nodes array, no matter how many there are.
Comments
Post a Comment