Prototype and Witch's Brew
When things work differently in one part of a package than they do in another - for no apparently good reason - programming indigestion may occur. When you beat your head against the code for too long trying to figure out why things are screwing up, big headaches are sure to come. The cause of my current indigestion and headache? `Element.insert` in Prototype. I have some javascript code that renders a string containing some HTML to be added to the bottom of the contents of a some target element. I do the necessary incantation, {% highlight javascript %} Element.insert('target',htmlString) {% endhighlight %} Which quite promptly does nothing. WTF? It turns out that the htmlString I'm sending either needs a javascript `toElement` method defined that will convert it into a DOM object or it must be a DOM object already. The first alternative is unpalatable - I just want to create html, not a tree of DOM cruft. The second is just as bad, unless I can get the work done for me. Fortunately, I can. In the body of my document, I declare a special, invisible div, {% highlight html %}