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 */
Hi, isnt this functionality already covered by script.aculo.us''s Builer.node()? Sure thats not Prototype, but that Builder rocks IMHO. greets 2006/7/24, Claudio Gamboa <gamboa-Gfo+GL0gMlAAvxtiuMwx3w@public.gmane.org>:> > 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 > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Michael Siebert <info-norLuBQQNv0t+8dGM1inlw@public.gmane.org> www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hi, I didn''t know this Builder class. Thanks :) Ok, that class has more features, but we need to include another file when we will need include only prototype.js On Monday 24 July 2006 10:43, Michael Siebert wrote:> Hi, > isnt this functionality already covered by script.aculo.us''s Builer.node()? > Sure thats not Prototype, but that Builder rocks IMHO. > > greets > > 2006/7/24, Claudio Gamboa <gamboa-Gfo+GL0gMlAAvxtiuMwx3w@public.gmane.org>: > > 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 > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 7/24/06, Claudio Gamboa <gamboa-Gfo+GL0gMlAAvxtiuMwx3w@public.gmane.org> wrote:> > I didn''t know this Builder class. > Ok, that class has more features, but we need to include another file when we > will need include only prototype.jsSimply append it to the end of your existing prototype.js. :-) If you''re not already doing so, I''d also recommend using some sort of JS compressor on these libraries - you can typically save about 30% (before any savings gained from your server sending gzipped files automagically). Drew -- ---------------------------------------------------------------- Drew Taylor * Web development & consulting Email: drew-sYRLyna/r5E+Va1GwOuvDg@public.gmane.org * Site implementation & hosting Web : www.drewtaylor.com * perl/mod_perl/DBI/mysql/postgres ----------------------------------------------------------------
Claudio, I don''t know about the Builder class (I don''t use it), but your solution may not work when creating an input element with a "name" attribute in IE due to an obscure IE bug. See http://msdn.microsoft.com/library/default.asp?url=/workshop/ author/dhtml/reference/properties/name_2.asp and a solution here http://alt-tag.com/blog/archives/2006/02/ie-dom- bugs/ (Thanks to Bennett McElwee) TAG tomg-PGZyUNKar/Q@public.gmane.org On Jul 24, 2006, at 3:43 AM, Michael Siebert wrote:> Hi, > isnt this functionality already covered by script.aculo.us''s > Builer.node()? Sure thats not Prototype, but that Builder rocks IMHO. > > greets > > 2006/7/24, Claudio Gamboa <gamboa-Gfo+GL0gMlAAvxtiuMwx3w@public.gmane.org>: > 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 > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > -- > Michael Siebert <info-norLuBQQNv0t+8dGM1inlw@public.gmane.org> > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Claudio, I don''t know about the Builder class (I don''t use it), but your solution may not work when creating an input element with a "name" attribute in IE due to an obscure IE bug. See http://msdn.microsoft.com/library/default.asp?url=/workshop/ author/dhtml/reference/properties/name_2.asp and a solution here http://alt-tag.com/blog/archives/2006/02/ie-dom- bugs/ (Thanks to Bennett McElwee) TAG tomg-PGZyUNKar/Q@public.gmane.org . On Jul 24, 2006, at 3:43 AM, Michael Siebert wrote:> Hi, > isnt this functionality already covered by script.aculo.us''s > Builer.node()? Sure thats not Prototype, but that Builder rocks IMHO. > > greets > > 2006/7/24, Claudio Gamboa <gamboa-Gfo+GL0gMlAAvxtiuMwx3w@public.gmane.org>: > 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 > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > -- > Michael Siebert <info-norLuBQQNv0t+8dGM1inlw@public.gmane.org> > > www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs