Hi everybody

I wrote this new method for prototype Element. 
I don't know why this does not exist yet. 

With this method we can create a new element and it will be returned. 

The patch is:

----------------------------- start ------------------------

--- prototype.orig.js   2006-07-24 03:14:58.000000000 +0100
+++ prototype.js    2006-07-24 02:48:08.000000000 +0100
@@ -921,6 +921,15 @@
     return $(element).style.display != 'none';
   },

+  create: function(tagname, prop) {
+     var elm = document.createElement(tagname);
+     $H(prop).each(function(pair) {
+        elm.setAttribute(pair[0], pair[1]);
+        }
+     ); 
+     return elm;
+  },
+
   toggle: function() {
     for (var i = 0; i < arguments.length; i++) {
       var element = $(arguments[i]);
@@ -2003,4 +2012,4 @@

     return [valueL, valueT];
   }
-}
\ No newline at end of file
+}


----------------------------- end -------------------------


HowTo: 

first -  check http://pdvel.com/stuff/js/createelement/  
then - view source :) 


/**
* Claudio Gamboa
* gamboa(AT_NO_SPAM)pdvel.com
* gamboa(AT_NOT_SPAM)co.sapo.pt 
*/
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to