Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: tracking where I am in a tree structure

by agaffney (Beadle)
on Jul 22, 2004 at 22:07 UTC ( [id://376739]=note: print w/replies, xml ) Need Help??


in reply to Re: tracking where I am in a tree structure
in thread tracking where I am in a tree structure

That was the type of thing I was trying to put together in my head, but for some reason it just wouldn't come together. That code seems to work perfectly, although, I haven't tested it more than 1 level deep, yet.

As for the DIV problem, how would you suggest fixing that?
  • Comment on Re^2: tracking where I am in a tree structure

Replies are listed 'Best First'.
Re^3: tracking where I am in a tree structure
by stvn (Monsignor) on Jul 22, 2004 at 22:20 UTC
    That was the type of thing I was trying to put together in my head, but for some reason it just wouldn't come together.

    Recursive solutions always are harder to wrap your head around, they tend require more "faith" than iterative solutions, and that is not something most programmers are usually accustomed too (all relgious meanings aside of course).

    As for the DIV problem, how would you suggest fixing that?

    Well not having seen your output I am not sure, but I would suspect you could try putting the 'onClick' handler in the tag you are writing, rather than wrapping that tag. Although this may have the same effect when you are dealing with things like TABLE, TR, UL tags, since they too are container tags which sometimes "enclose" their descendents. The other option, and I am not sure if this would be appropriate or not, is to only wrap your leaf nodes with the "onClick" since they are likely to be text nodes and the like (although things like BR and HR will fall into that category too). Hard to really say without either having some test data, or knowing more about what you want the UI to do in the end.

    -stvn
      The purpose of this whole thing is to build an online HTML editor with simple support for TABLEs, Ps, SPANs, Bs, As, and a few pre-defined CSS styles.

      After the HTML is parsed, it is regenerated from the tree for viewing in a preview window. I have the DIVs because I want a way to highlight the various elements of the page. When the user clicks (or double clicks) inside one of these DIVs, it will refresh the page with another parameter ($nodeid) that tells which element in the page they selected.

      I am doing all of this because my boss (uses Frontpage and loves the <BLINK> tag) insists on being able to edit content on our new HTML::Mason based site.

        Good Luck, I can't even begin to think of what would be the best way to go about all that. It has also been a while since I was really up to date with the whole DHTML thing. Best advice I can give, is don't listen to me, and 1) try things out to see what works, 2) find a good DHTML/Javascript mailing-list/board like this one to bounce things off of.

        -stvn
      Recursive solutions always are harder to wrap your head around, they tend require more "faith" than iterative solutions, and that is not something most programmers are usually accustomed too (all relgious meanings aside of course).

      Piffle. Recursion is neither magical nor obscure, especially when dealing with recursive data structures (like parse trees).

      --
      F o x t r o t U n i f o r m
      Found a typo in this node? /msg me
      % man 3 strfry

        Piffle. Recursion is neither magical nor obscure, especially when dealing with recursive data structures (like parse trees).

        I never said it was magical or obscure. Only that for a programmer trained to think iteratively (as most are), the concept of recursion can sometimes take some getting used to.

        Clearly to you it is nothing magical, as you understand it quite well (as evidenced by many of your recent posts, and particulary your ones on Haskell). But to some, it is a concept that does not sit as easily.

        -stvn

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://376739]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-26 03:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found