![]() |
javascript - having a problem recusively visiting elements...
I'm making my own little ajax-ish directory browser. Not sure if I'm doing it the best way, but, in short, the way it works is that every table row has an id for the directory it holds and an id for that directory's parent. From that, i can use styles to collapse or "uncollapse" a row, so you can click on a directory in the browser to see what's in that directory without reloading the page.
This works fine for expanding the directories, but when i go to collapse them, I'm not collapsing all subdirs - just one level down (all subdirs more than one level down remain - assuming they've been expanded). Here's the javascript: Code:
function coll(thing) { Code:
<tr id="0" inode="13238975" parent="13189260"> if I've been clicked and my children are collapsed - make them visible if I've been clicked and my children are visible - visit each of my children recursively & collapse them You can see this all in action here. Expand all the links then try to collapse at the top level to see what I'm talking about. ... any idea why the recursive collapse isn't working? |
The issue is probably "pass by value" vs "pass by reference".
To recurse, you generally need to "pass by value" (make a copy of the value in question to pass down to the subroutine). Passing an object reference (like "me") is, of course, passing by reference: the subroutine is using *the same* object as the original caller. Recursion works fine with values like "int". It also works fine where you can pass a pointer like "mytree.next". Here are a couple of examples: http://lists.evolt.org/pipermail/jav...ay/000601.html http://www.devx.com/xml/Article/11866/1954?pf=true |
Quote:
regardless, if I say something like me2 = me; & then pass me2, that still doesn't work, unless that assignment is also just some sort of pointer. |
sigh... typo
Quote:
|
All times are GMT -5. The time now is 09:04 PM. |