This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[AJAX] Making the jump from global scope to local scope

 
Barend Garvelink
Ranch Hand
Posts: 64
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ryan and Nathanial,



I recently wrote a client-side treeview control using AJAX technology, firing XmlHttpRequest whenever a node was doubleclicked to fetch its contents. The system was set-up as a client-side object graph, that recursively writes itself into the HTML DOM whenever something changed. The Javascript object graph was king; you could say that the DOM was "slaved" to its state changes (albeit via a push mechanism).

One of the harder nuts to crack was how to make the jump from the onreadystatechange method back into my object-oriented scope. I tackled it using the Function() constructor to hard-code the path to my node into each event handler. The root node rested in global-scope, and a recursive lookup function did the rest. This way, I was able to keep track of multiple XmlHttpRequests at once, but it never did feel like a pretty solution. I ended up with multiple (okay, two) hashtable objects in the global scope just to tie up all my event handlers.

I wonder if your book addresses the issues that come with firing multiple XmlHttpRequests at once, and with connecting what's essentially a Visual Basic control to an object-oriented world. Did I overlook something blindingly obvious?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic