update: July 5, 2007: see ID Proliferation Eradication Technique #1… for an update.
The Prototype Updater constructor takes an Element (object) or element id (String) as the first parameter. You can see this in prototype.js in Abstract.Insertion.initialize and Ajax.Updater.updateContent . In both situations the first parameter sent to the constructor has $() applied before use. And as I’m sure you’re aware, the effect of that is that if the parameter is an Element, then the same element is returned. OTOH, if the element is a String, then that string is assumed to be an element id and the Element is found in the DOM and returned.
1 update_page do |page| 2 page.insert_html :bottom, page.select('p.welcome b').first, "<li> </li>" 3 page.visual_effect :highlight, 'list' 4 page.hide 'status-indicator', 'cancel-link' 5 end
Note that instead of the simple string literal ‘list’ (from the Rails doc) we’ve got a full-fledged expression there. And generate something like this:
1 new Insertion.Bottom($$('p.welcome b').first, "<li>Some item</li>"); 2 new Effect.Highlight('list'); 3 ["status-indicator", "cancel-link"].each(Element.hide);