hi all i googled and read the docs but couldn''t find anything. maybe i''m blind but hopefully someone will enlighten me. the functions insert and update take just a string as argument of what to insert. but i would like to insert an element. is there a way to get a string of the element containing the whole subtree of nodes? for example: Element.update(element, anotherelement); the the element will show something like [Object HTMLelement]. is it possible at all to get the subtree of an element as string or is element just a pointer to a certain node? TIA simon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> hi all > > i googled and read the docs but couldn''t find anything. maybe i''m > blind but hopefully someone will enlighten me. > the functions insert and update take just a string as argument of what > to insert. but i would like to insert an element. > is there a way to get a string of the element containing the whole > subtree of nodes? > > for example: > Element.update(element, anotherelement); > the the element will show something like [Object HTMLelement]. > > is it possible at all to get the subtree of an element as string or is > element just a pointer to a certain node?never mind. i found it out. innerHTML is my friend. thanks simon> > TIA > > simon > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 24, 10:08 pm, simon <si...-90m6e4VxeoY@public.gmane.org> wrote:> > hi all > > > i googled and read the docs but couldn''t find anything. maybe i''m > > blind but hopefully someone will enlighten me. > > the functions insert and update take just a string as argument of what > > to insert. but i would like to insert an element. > > is there a way to get a string of the element containing the whole > > subtree of nodes? > > > for example: > > Element.update(element, anotherelement); > > the the element will show something like [Object HTMLelement]. > > > is it possible at all to get the subtree of an element as string or is > > element just a pointer to a certain node? > > never mind. i found it out. innerHTML is my friend.If you are moving an existing element and all its children, all you need to do is attach it to its new location in the DOM using appendChild. Using innerHTML to get the string, then parse it back into the DOM using innerHTML again is just plain silly. There is no standard for innerHTML and it is implemented differently in different browsers, you will likely encounter quirks if you persist with that strategy. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RobG schrieb:> > On Oct 24, 10:08 pm, simon <si...-90m6e4VxeoY@public.gmane.org> wrote: > >>> hi all >>> >>> i googled and read the docs but couldn''t find anything. maybe i''m >>> blind but hopefully someone will enlighten me. >>> the functions insert and update take just a string as argument of what >>> to insert. but i would like to insert an element. >>> is there a way to get a string of the element containing the whole >>> subtree of nodes? >>> >>> for example: >>> Element.update(element, anotherelement); >>> the the element will show something like [Object HTMLelement]. >>> >>> is it possible at all to get the subtree of an element as string or is >>> element just a pointer to a certain node? >>> >> never mind. i found it out. innerHTML is my friend. >> > > If you are moving an existing element and all its children, all you > need to do is attach it to its new location in the DOM using > appendChild. >ok. thanks for the hint. will have a look at it and try it out.> Using innerHTML to get the string, then parse it back into the DOM > using innerHTML again is just plain silly.i actually don''t use innerHTML to write it back, i use Element.update(...).> There is no standard for > innerHTML and it is implemented differently in different browsers, you > will likely encounter quirks if you persist with that strategy. >it''s just a really small script and i tested it in all major browser and it works fine so far. but anyway thanks very much for your comment. cheers simon> > -- > Rob > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Nov 3, 11:43 pm, simon <si...-90m6e4VxeoY@public.gmane.org> wrote:> RobG schrieb:[...]> > If you are moving an existing element and all its children, all you > > need to do is attach it to its new location in the DOM using > > appendChild. > > ok. thanks for the hint. will have a look at it and try it out.> Using innerHTML to get the string, then parse it back into the DOM > > using innerHTML again is just plain silly. > > i actually don''t use innerHTML to write it back, i use Element.update(...).Element.update uses it, otherwise it would have to parse the HTML itself (which would be a bit silly if the innerHTML property is available).> > There is no standard for > > innerHTML and it is implemented differently in different browsers, you > > will likely encounter quirks if you persist with that strategy. > > it''s just a really small script and i tested it in all major browser and > it works fine so far. > but anyway thanks very much for your comment.Incompatibilities can arise in even trivial scripts - try the example below in IE and Firefox. Change the text in the input and note the value attribute reported by innerHTML. <div id="a""> <input type="text" value="original value"> <button onclick="alert($(''a'').innerHTML);">Show div innerHTML</ button> </div> -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---