Hey everyone, I'm wondering if this has already been thought of or not, but I have a simple idea that could really improve dynamic creation of elements in prototype.
Here's the methods: Element.addMethods({ build: function(element, type, options, style) { newElement = Element.build(type, options, style); element.appendChild(newElement); return newElement; } }); Element.build = function(type, options, style) { e = $(document.createElement(type)); $H(options).each(function(pair) { eval("e." + pair.key + " = pair.value" ); }); if (style) $H(style).each(function(pair) { eval("e.style." + pair.key + " = pair.value" ); }); return e; }; =-=-=-= It changes this: my_div = $(document.createElement("div")); my_h1 = $(document.createElement("h1")); my_h1.innerHTML = "Hello there!"; my_text = $(document.createElement("p")); my_text.innerHTML = "Hello, here is some text"; my_text.style.fontSize = "25px"; my_div.appendChild(my_h1); my_div.appendChild(my_text); into this: my_div = Element.build("div"); my_div.build("h1", { innerHTML: "Hello there!" } ); my_div.build("p", { innerHTML: "Hello, here is some text" }, { fontSize: "25px"}); Would such an enhancement be welcomed by the prototype core team? Tim --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---