Quite often I create large chunks of HTML in javascript and use the
prototype new Element method. I like this method because you can chain
it with other methods, and create clean readable code. However, after
I create an element I usually want to append it to a parent element
first thing. I can do this in two lines of code with appendChild, but
that doesn't seem very "prototypish". My solution was to add a
Element.setParent function. Is there a core method I can use that does
this better, or is setParent the away to go? I looked at insert, but
its the other way around parent to child.
Example:
var divPane = new Element('div', {'class':'sv_panel' +
this._className });
var divContainer = new Element('div',
{'class':'container'}).setParent(divPanel);
var divTitleBar = new Element('div',
{'class':'titlebar'}).setParent(divContainer).update("My Titlebar');
....
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---