abonhomme
2007-Sep-17 11:23 UTC
Prototype: inserting multiple tbody elements (possible in IE?)
I apologize in advance if this has been covered before, but I examined the code, searched the list and the web and came up nothing useful. Is it possible using the prototype library to insert multiple TBODY elements into a table at once AND have it work in Internet Explorer? In other words, using an html snippet, that has multiple tbody elements, as the second argument to the Insertion classes. I''m using IE 7 at the moment, but I would hope for this to work equally well for as low as IE 5.5 or at least IE 6. I have tried the following methods. Please assume the following: - html is a well-formed snippet of html containing multiple tbody elements - the table, tHead, tBody variables are the respective table elements - the tBody variable represents an empty placeholder TBODY element new Insertion.Bottom(table,html); //line 1 new Insertion.Before(tBody,html); //line 2 new Insertion.After (tBody,html); //line 3 new Insertion.After (tHead,html); //line 4 tBody.replace(html); //line 5 tBody.update(html); //line 6 In Firefox all of the above methods, except the last one, produce the desired effect; the new tbody elements were added to the table. The last one, line 6, does insert the html, it''s just not formatted like a table; I would assume that''s because the original tbody, now contains the additional tbody elements from the html snippet. But this is fine, because the original intent is possible with any of the first five lines. So on to where the problem lies...... In IE7 (cant'' say about other versions), none of those lines produce the desired effect. Lines 1 & 4 fail and produce the error message "Invalid target element for this operation." Lines 2 , 3, & 6 fail silently Line 5 fails and produce the error message "Unknown runtime error" I have tested this with Prototype version 1.5.0 and version 1.5.1.1. Having examined the code for Prototype in both versions, I''m not sure I would expect inserting multiple tbody elements in a single html snippet to work at all. Lines 1955 - 1957 from version 1.51.1 are below. 1955 | var div = document.createElement(''div''); 1956 | div.innerHTML = ''<table><tbody>'' + this.content + ''</tbody></ table>''; 1957 | return $A(div.childNodes[0].childNodes[0].childNodes); If the html content on #1956 contains multiple tbody elements, IE responds by producing a table with 2 extra tbody elements (one element before the inserted html, and one after). So the result of #1957 will always be an empty array, which explains why some of my examples above fail silently (basically results in a no-op). I hope I have stated this clearly, and if necessary I can post the test cases I used in my experiments. I can make this work in IE while still using browser neutral techniques, but just wanted to ensure that I wasn''t missing something simple in the Insertion classes that would do this for me. Thanks! --~--~---------~--~----~------------~-------~--~----~ 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
2007-Sep-17 13:53 UTC
Re: Prototype: inserting multiple tbody elements (possible in IE?)
On Sep 17, 9:23 pm, abonhomme <jum...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I apologize in advance if this has been covered before, but I examined > the code, searched the list and the web and came up nothing useful. > > Is it possible using the prototype library to insert multiple TBODY > elements into a table at once AND have it work in Internet Explorer? > In other words, using an html snippet, that has multiple tbody > elements, as the second argument to the Insertion classes. > > I''m using IE 7 at the moment, but I would hope for this to work > equally well for as low as IE 5.5 or at least IE 6. > > I have tried the following methods. > Please assume the following: > - html is a well-formed snippet of html containing multiple tbody > elements > - the table, tHead, tBody variables are the respective table elements > - the tBody variable represents an empty placeholder TBODY element > > new Insertion.Bottom(table,html); //line 1 > new Insertion.Before(tBody,html); //line 2 > new Insertion.After (tBody,html); //line 3 > new Insertion.After (tHead,html); //line 4 > tBody.replace(html); //line 5 > tBody.update(html); //line 6 > > In Firefox all of the above methods, except the last one, produce the > desired effect; the new tbody elements were added to the table. The > last one, line 6, does insert the html, it''s just not formatted like a > table; I would assume that''s because the original tbody, now contains > the additional tbody elements from the html snippet. But this is > fine, because the original intent is possible with any of the first > five lines. > > So on to where the problem lies...... > > In IE7 (cant'' say about other versions), none of those lines produce > the desired effect. > Lines 1 & 4 fail and produce the error message "Invalid target element > for this operation." > Lines 2 , 3, & 6 fail silently > Line 5 fails and produce the error message "Unknown runtime error" > > I have tested this with Prototype version 1.5.0 and version 1.5.1.1. > > Having examined the code for Prototype in both versions, I''m not sure > I would expect inserting multiple tbody elements in a single html > snippet to work at all. Lines 1955 - 1957 from version 1.51.1 are > below. > > 1955 | var div = document.createElement(''div''); > 1956 | div.innerHTML = ''<table><tbody>'' + this.content + ''</tbody></ > table>''; > 1957 | return $A(div.childNodes[0].childNodes[0].childNodes); > > If the html content on #1956 contains multiple tbody elements, IE > responds by producing a table with 2 extra tbody elements (one element > before the inserted html, and one after).That may be what is in the HTML, however a tbody inside another tbody is invalid HTML. I don''t have IE 7, however I expect you can remove the tbody tags from line 1956 with complete safety - they aren''t required for valid HTML, I don''t know why they are there. The only reason to use tbody tags is if you have multiple tbody elements in one table, in which case the above code is bound to produce invalid HTML and you are at the mercy of browser error correction.> So the result of #1957 will > always be an empty array,That depends very much on what the browser is doing with the invalid HTML - can you provide a simple test case and the resultant HTML? -- 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 -~----------~----~----~----~------~----~------~--~---
abonhomme
2007-Sep-17 17:53 UTC
Re: Prototype: inserting multiple tbody elements (possible in IE?)
> That may be what is in the HTML, however a tbody inside another tbody > is invalid HTML. I don''t have IE 7, however I expect you can remove > the tbody tags from line 1956 with complete safety - they aren''t > required for valid HTML, I don''t know why they are there.While I realize that the result is invalid html, I''m not explicitly writing code that does this. It is is part of the Prototype library, so I don''t want change it and then have to maintain my own fork of the library. That''s a serious misuse of time.> > So the result of #1957 will > > always be an empty array, > > That depends very much on what the browser is doing with the invalid > HTMLI''m specifically talking about IE in this case.> can you provide a simple test case and the resultant HTML?If there are suggestions or insight that involves something other than modifying the Prototype library, then I''ll take the time to clean up my test cases and post them. I don''t intend to sound rude or offensive, but it seems that you may have missed the point of the original question. The original question, re-stated: Is there anything in Prototype''s Insertion classes (or anywhere in the entire Prototype API) that allows the insertion of new rows to a table via a well-formed html string containing multiple tbody elements. On Sep 17, 9:53 am, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> On Sep 17, 9:23 pm, abonhomme <jum...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I apologize in advance if this has been covered before, but I examined > > the code, searched the list and the web and came up nothing useful. > > > Is it possible using the prototype library to insert multiple TBODY > > elements into a table at once AND have it work in Internet Explorer? > > In other words, using an html snippet, that has multiple tbody > > elements, as the second argument to the Insertion classes. > > > I''m using IE 7 at the moment, but I would hope for this to work > > equally well for as low as IE 5.5 or at least IE 6. > > > I have tried the following methods. > > Please assume the following: > > - html is a well-formed snippet of html containing multiple tbody > > elements > > - the table, tHead, tBody variables are the respective table elements > > - the tBody variable represents an empty placeholder TBODY element > > > new Insertion.Bottom(table,html); //line 1 > > new Insertion.Before(tBody,html); //line 2 > > new Insertion.After (tBody,html); //line 3 > > new Insertion.After (tHead,html); //line 4 > > tBody.replace(html); //line 5 > > tBody.update(html); //line 6 > > > In Firefox all of the above methods, except the last one, produce the > > desired effect; the new tbody elements were added to the table. The > > last one, line 6, does insert the html, it''s just not formatted like a > > table; I would assume that''s because the original tbody, now contains > > the additional tbody elements from the html snippet. But this is > > fine, because the original intent is possible with any of the first > > five lines. > > > So on to where the problem lies...... > > > In IE7 (cant'' say about other versions), none of those lines produce > > the desired effect. > > Lines 1 & 4 fail and produce the error message "Invalid target element > > for this operation." > > Lines 2 , 3, & 6 fail silently > > Line 5 fails and produce the error message "Unknown runtime error" > > > I have tested this with Prototype version 1.5.0 and version 1.5.1.1. > > > Having examined the code for Prototype in both versions, I''m not sure > > I would expect inserting multiple tbody elements in a single html > > snippet to work at all. Lines 1955 - 1957 from version 1.51.1 are > > below. > > > 1955 | var div = document.createElement(''div''); > > 1956 | div.innerHTML = ''<table><tbody>'' + this.content + ''</tbody></ > > table>''; > > 1957 | return $A(div.childNodes[0].childNodes[0].childNodes); > > > If the html content on #1956 contains multiple tbody elements, IE > > responds by producing a table with 2 extra tbody elements (one element > > before the inserted html, and one after). > > That may be what is in the HTML, however a tbody inside another tbody > is invalid HTML. I don''t have IE 7, however I expect you can remove > the tbody tags from line 1956 with complete safety - they aren''t > required for valid HTML, I don''t know why they are there. > > The only reason to use tbody tags is if you have multiple tbody > elements in one table, in which case the above code is bound to > produce invalid HTML and you are at the mercy of browser error > correction. > > > So the result of #1957 will > > always be an empty array, > > That depends very much on what the browser is doing with the invalid > HTML - can you provide a simple test case and the resultant HTML? > > -- > 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 -~----------~----~----~----~------~----~------~--~---