Simple question, which I should probably know the answer to, but how do I convert a prototype element to the raw HTML? Cheers Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You could, for example, use Firebug to examine the generated DOM On Feb 4, 2008 12:52 PM, ChrisT <ctmailinglists-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > Simple question, which I should probably know the answer to, but how > do I convert a prototype element to the raw HTML? > > Cheers > > Chris > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris, Unfortunately, only IE has outerHTML (which is what you need). You could try something like this: Element.addMethods({ toOuterHTML: function(element) { return $(element).cloneNode(true).wrap().innerHTML; } }) ... <p class="foo" id="bar">blah</p> ... $(''bar'').toOuterHTML(); // => "<p class=''foo'' id=''bar''>blah</p>" Best, kangax --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It''s not a question of examining it, I need to insert it into an function (defined in external library) that only accepts a string (not elements). For the moment, I''ve built up the HTML string by hand rather than using new Element("p",....).update(...). It''s not I big problem (and is probably quicker), but just assumed I was missing something. Cheers Chris On 4 Feb, 12:24, "Deniz Adrian" <deniz.adr...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> You could, for example, use Firebug to examine the generated DOM > > On Feb 4, 2008 12:52 PM, ChrisT <ctmailingli...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > > Simple question, which I should probably know the answer to, but how > > do I convert a prototype element to the raw HTML? > > > Cheers > > > Chris--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Kangax approach seems to be ideal for the scenario but I think you''ll need to extend the cloned object before invoking wrap. On Feb 4, 7:09 am, ChrisT <ctmailingli...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> It''s not a question of examining it, I need to insert it into an > function (defined in external library) that only accepts a string (not > elements). For the moment, I''ve built up the HTML string by hand > rather than using new Element("p",....).update(...). > It''s not I big problem (and is probably quicker), but just assumed I > was missing something. > > Cheers > Chris > > On 4 Feb, 12:24, "Deniz Adrian" <deniz.adr...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > You could, for example, use Firebug to examine the generated DOM > > > On Feb 4, 2008 12:52 PM, ChrisT <ctmailingli...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > > Simple question, which I should probably know the answer to, but how > > > do I convert a prototype element to the raw HTML? > > > > Cheers > > > > Chris--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Amazing, but cloneNode(true) actually returns extended element in IE : ) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Kangax: really ? On Feb 5, 4:02 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Amazing, but cloneNode(true) actually returns extended element in > IE : )--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I have tested IE6, and it''s unbeleivable but it''s true :) On Feb 5, 2008, at 4:11 AM, Tobie Langel wrote:> > Kangax: really ? > > On Feb 5, 4:02 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Amazing, but cloneNode(true) actually returns extended element in >> IE : ) > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Duh! That''s actually the trick we use to speed up new Element()... Looks like my memory is going down the drain. On Feb 5, 7:22 am, Sébastien Gruhier <sgruh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have tested IE6, and it''s unbeleivable but it''s true :) > > On Feb 5, 2008, at 4:11 AM, Tobie Langel wrote: > > > Kangax: really ? > > > On Feb 5, 4:02 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Amazing, but cloneNode(true) actually returns extended element in > >> IE : )--~--~---------~--~----~------------~-------~--~----~ 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 Feb 4, 11:03 pm, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Chris, > > Unfortunately, only IE has outerHTML (which is what you need).Gecko browsers have XMLSerializer , as do a number of others such as Opera and Safari (but not IE): <URL: http://developer.mozilla.org/en/docs/XMLSerializer > You can use outerHTML for IE and for the others something like: new XMLSerializer().serializeToString(element) Opera also supports useful parts of the W3C DOM 3 Load and Save spec. that others don''t. <URL: http://www.w3.org/TR/DOM-Level-3-LS/ > While the above are aimed at XML, they work quite nicely with HTML.> You could try something like this: > > Element.addMethods({ > toOuterHTML: function(element) { > return $(element).cloneNode(true).wrap().innerHTML;innerHTML is not particularly reliable across browsers if you modify the element dynamically. -- 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 -~----------~----~----~----~------~----~------~--~---