Having just come up against the readonly nature of TBODY.innerHTML on IE, I assume that using the DOM methods will work better in all browsers? On 02/03/07, Mislav Marohnić <mislav.marohnic@gmail.com> wrote:> On 3/2/07, Richard Quadling <rquadling@googlemail.com> wrote: > > > > I have used 2 ways of adding new elements to the document at run time. > > > > One way is to use innerHTML and the other is to use > > createElement/appendChild/etc. > > With Prototype, you should have used Insertion (see the docs). > > Which is "better" and why? > > Insertion (innerHTML-powered) is better for HTML fragments (multiple > elements) and avoiding some nasty browser bugs related to setting certain > attributes. DOM methods (createElement ...) are better because you instantly > have the reference to the element and the flexibility of juggling it around. > > In short: have some HTML in a string? Use Insertion. Otherwise, mostly use > DOM methods. > > > Is there an alternative way? > > Yeah, cloning a node that already exists and then updating it (and its > contents). That's kinda advanced. > > There are also DOM builders - see the recent discussion about them (useful > links inside!). > In future, don't ask questions like these on this group, ask them on > "Spinoffs". "Core" is not a support group. > > > >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
The DOM API has it''s own cross-browser issues (not the fault of the API, but the browsers...). To avoid these, you can to use .update() and .replace() (which are Prototype methods) to correctly update and replace elements. These methods include automatic workarounds for (mostly IE) issues. See http://prototypejs.org/api/element/update for more on this. If you do heavy DOM lifting, you probably want to use a DOM builder, that add similar workarounds when doing more "low-level" work, like Mislav suggests. Best, Thomas Am 06.03.2007 um 13:57 schrieb Richard Quadling:> Having just come up against the readonly nature of TBODY.innerHTML on > IE, I assume that using the DOM methods will work better in all > browsers? > > > On 02/03/07, Mislav Marohnić <mislav.marohnic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 3/2/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >>> >>> I have used 2 ways of adding new elements to the document at run >>> time. >>> >>> One way is to use innerHTML and the other is to use >>> createElement/appendChild/etc. >> >> With Prototype, you should have used Insertion (see the docs). >>> Which is "better" and why? >> >> Insertion (innerHTML-powered) is better for HTML fragments (multiple >> elements) and avoiding some nasty browser bugs related to setting >> certain >> attributes. DOM methods (createElement ...) are better because you >> instantly >> have the reference to the element and the flexibility of juggling >> it around. >> >> In short: have some HTML in a string? Use Insertion. Otherwise, >> mostly use >> DOM methods. >> >>> Is there an alternative way? >> >> Yeah, cloning a node that already exists and then updating it (and >> its >> contents). That''s kinda advanced. >> >> There are also DOM builders - see the recent discussion about them >> (useful >> links inside!). >> In future, don''t ask questions like these on this group, ask them on >> "Spinoffs". "Core" is not a support group. >> >>> >> > > > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php? > c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > > >-- Thomas Fuchs wollzelle http://www.wollzelle.com questentier on AIM madrobby on irc.freenode.net http://www.fluxiom.com :: online digital asset management http://script.aculo.us :: Web 2.0 JavaScript http://mir.aculo.us :: Where no web developer has gone before --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
WOW! Update works fine. Why it works, I can't quite work out, but hey! That's another job done for me. Thank you all. Richard. On 06/03/07, Thomas Fuchs <t.fuchs@wollzelle.com> wrote:> > The DOM API has it's own cross-browser issues (not the fault of the > API, but the browsers...). > > To avoid these, you can to use .update() and .replace() (which are > Prototype methods) to correctly update and replace elements. These > methods include automatic workarounds for (mostly IE) issues. > > See http://prototypejs.org/api/element/update for more on this. > > If you do heavy DOM lifting, you probably want to use a DOM builder, > that add similar workarounds when doing more "low-level" work, like > Mislav suggests. > > Best, > Thomas > > Am 06.03.2007 um 13:57 schrieb Richard Quadling: > > > Having just come up against the readonly nature of TBODY.innerHTML on > > IE, I assume that using the DOM methods will work better in all > > browsers? > > > > > > On 02/03/07, Mislav Marohnić <mislav.marohnic@gmail.com> wrote: > >> On 3/2/07, Richard Quadling <rquadling@googlemail.com> wrote: > >>> > >>> I have used 2 ways of adding new elements to the document at run > >>> time. > >>> > >>> One way is to use innerHTML and the other is to use > >>> createElement/appendChild/etc. > >> > >> With Prototype, you should have used Insertion (see the docs). > >>> Which is "better" and why? > >> > >> Insertion (innerHTML-powered) is better for HTML fragments (multiple > >> elements) and avoiding some nasty browser bugs related to setting > >> certain > >> attributes. DOM methods (createElement ...) are better because you > >> instantly > >> have the reference to the element and the flexibility of juggling > >> it around. > >> > >> In short: have some HTML in a string? Use Insertion. Otherwise, > >> mostly use > >> DOM methods. > >> > >>> Is there an alternative way? > >> > >> Yeah, cloning a node that already exists and then updating it (and > >> its > >> contents). That's kinda advanced. > >> > >> There are also DOM builders - see the recent discussion about them > >> (useful > >> links inside!). > >> In future, don't ask questions like these on this group, ask them on > >> "Spinoffs". "Core" is not a support group. > >> > >>> > >> > > > > > > -- > > ----- > > Richard Quadling > > Zend Certified Engineer : http://zend.com/zce.php? > > c=ZEND002498&r=213474731 > > "Standing on the shoulders of some very clever giants!" > > > > > > > -- > Thomas Fuchs > wollzelle > > http://www.wollzelle.com > > questentier on AIM > madrobby on irc.freenode.net > > http://www.fluxiom.com :: online digital asset management > http://script.aculo.us :: Web 2.0 JavaScript > http://mir.aculo.us :: Where no web developer has gone before > > > > > > > >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---