Yay! i learned my HTML tip-of-the-day: multiple TBODY tags! Now, i'm
off to find an excuse to use it.
-joe t.


On Feb 16, 12:38 pm, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
> Hi,
>
> > For some reason never learned about the tbody element.  When did
> > that get added to the spec
>
> Proposed in 1996, standardized in HTML 4.01 in 1999.[1] It's a cool
> element, because amongst other things, you can have more than one of
> them. So if you have a table with rows you want to replace and other
> rows you don't, you can put them in separate TBODYs and group them
> that way.
>
> AFAIK, it's always been optional (officially optional) in the *markup*
> (it certainly is in HTML5), but that's in the markup; in standards
> mode, browsers have been inserting it in the DOM for you for years.
> For example:http://jsbin.com/urito5If you run that on IE6, IE7, IE8,
> Chrome, Firefox, or Opera, they'll all say the only child element of
> the TABLE element is a TBODY, although there's no TBODY in the markup.
>
> Interestingly, HTML5 seems to allow TR to be a direct child of TABLE,
> even in the DOM[2]. That surprises me, I thought it was just in the
> list of elements that an engine was meant to infer.[3] I'm probably
> just misreading the spec. I always explicitly include TBODY if there's
> any chance I'm going to need to manipulate the DOM at the table level,
> just so I know where I am even on "edge" browsers.
>
> 1:http://www.w3.org/TR/html4/struct/tables.html#edef-TBODY
> 2:http://www.w3.org/TR/html5/tabular-data.html#the-table-element
> 3:http://www.w3.org/TR/html5/syntax.html#optional-tags
>
> Best,
> --
> T.J. Crowder
> Independent Software Engineer
> tj / crowder software / com
> www / crowder software / com
>
> On Feb 16, 4:37 pm, Jeffrey Lee <jlee...@gmail.com> wrote:
>
>
>
>
>
>
>
> > That will teach me to rely on google and random discussions online. :)  I 
> > was suspicious that the <div> was in an awkward location, but hadn't come 
> > up with a good way to replace just the body of the table.  For some reason 
> > never learned about the tbody element.  When did that get added to the 
> > spec, or has that always been there and just not used by hacks like me?  
> > Granted the last time I spent any energy on creating and editing web pages 
> > before this year was in the late 90's.
> > ___________________________
> > Jeffrey Leehttp://www.jeffreyalanlee.com
> > jlee...@gmail.com
>
> > On Feb 16, 2011, at 8:28 , Walter Lee Davis wrote:
>
> > > Not in my memory of HTML, which begins in 1997. It's certainly possible 
> > > to put that into a browser and see something. Browsers are designed to 
> > > ignore or coerce invalid code as best they can, to preserve the intent 
> > > where possible. But there's a mile of difference between the JavaScript 
> > > DOM interpreter and the browser's HTML display engine.
>
> > > JavaScript doesn't even receive the HTML as written in code from the 
> > > browser when it's constructing its starting DOM tree, it uses the output 
> > > of the browser's first pass at munging the input code stream into shape. 
> > > This is why you can see a big difference between Firebug and view source, 
> > > for example.
>
> > > So whenever you are interacting directly with the DOM, as you do in 
> > > Prototype Element#update or anything else that inserts elements into the 
> > > DOM, you are relied on to insert something that makes sense in the 
> > > context where it will be added. If you don't, you get an error or you get 
> > > ignored.
>
> > > One other example of this, directly related to tables: It's perfectly 
> > > valid code to write <table id="foo"><tr><td>Something</td></tr></table>, 
> > > but it's more correct to write <table 
> > > id="foo"><tbody><tr><td>Something</td></tr></tbody></table>. Most 
> > > browsers will silently add that missing intermediate element when the 
> > > page loads.
>
> > > So if you wanted to get a handle on your first row, and you used 
> > > $('foo').childElements()[0] (totally made-up example) then you might 
> > > actually get a reference to the tbody -- the element you didn't actually 
> > > code!
>
> > > Now you're probably smarter than that, and you'd write 
> > > $('foo').down('tr') and get what you wanted, but that's just an example 
> > > to make the point that the code you wrote isn't even guaranteed to be the 
> > > code you're going to be talking to when you start messing with the DOM.
>
> > > Walter
>
> > > On Feb 16, 2011, at 10:15 AM, Jeffrey Lee wrote:
>
> > >> Shows how outdated my HTML is.  Thanks for the pointer.  Its funny, when 
> > >> I was googling around apparently once upon a time it was at least 
> > >> tolerated, if not officially acceptable, to have <div> as a child of 
> > >> table.
> > >> ___________________________
> > >> Jeffrey Lee
> > >>http://www.jeffreyalanlee.com
> > >> jlee...@gmail.com
>
> > >> On Feb 15, 2011, at 23:20 , T.J. Crowder wrote:
>
> > >>> Hi,
>
> > >>> That HTML is invalid. You can't have a `div` as a child of `table`:
> > >>>http://www.w3.org/TR/html5/tabular-data.html#the-table-element
>
> > >>> If you want to subdivide a table like that, you probably want `thead`
> > >>> (for your headers) and one or more `tbody` elements:
>
> > >>> <table>
> > >>> <thead>
> > >>>  <tr>
> > >>>    <th>Item</th>
> > >>>     <th>Transaction Type</th>
> > >>>     <th>Quantity</th>
> > >>>    <th>Amount</th>
> > >>>     <th>Transaction comments</th>
> > >>>  </tr>
> > >>> </thead>
> > >>> <tbody id = "transList">
> > >>>  <tr>
> > >>>    <<bunch of table data>>
> > >>>  </tr>
> > >>>  <tr>
> > >>>    <<bunch of table data>>
> > >>>  </tr><tr>
> > >>>     <<bunch of table data>>
> > >>>  </tr>
> > >>> </tbody>
> > >>> </table>
>
> > >>> ...and then your update will have to be valid `tbody` content (e.g.,
> > >>> rows).
>
> > >>> Example:
> > >>>http://jsbin.com/evuxe3
>
> > >>> HTH,
> > >>> --
> > >>> T.J. Crowder
> > >>> Independent Software Engineer
> > >>> tj / crowder software / com
> > >>> www / crowder software / com
>
> > >>> On Feb 15, 10:59 pm, Jeff <jlee...@gmail.com> wrote:
> > >>>> This is a rails generated webpage.  I've created a table definition as
> > >>>> follows:
>
> > >>>> <table>
> > >>>> <tr>
> > >>>>   <th>Item</th>
> > >>>>   <th>Transaction Type</th>
> > >>>>   <th>Quantity</th>
> > >>>>   <th>Amount</th>
> > >>>>   <th>Transaction comments</th>
> > >>>> </tr>
>
> > >>>> <div id = "transList">
> > >>>> <tr>
> > >>>>  <<bunch of table data>>
> > >>>> </tr><tr>
> > >>>>  <<bunch of table data>>
> > >>>> </tr><tr>
> > >>>>   <<bunch of table data>>
> > >>>> </tr>
> > >>>> </div>
> > >>>> </table>
>
> > >>>> If I execute a $('transList').update('Test') or frankly any other text
> > >>>> or html, the existing table data remains, and the updated text is
> > >>>> placed above the entire table.  However, if I do a view - >source,
> > >>>> this new data doesn't show up in the page source at all, only the old
> > >>>> table data.
>
> > >>>> I'm having this problem in both Safari and Firefox.  Any suggestions?
>
> > >>> --
> > >>> You received this message because you are subscribed to the Google 
> > >>> Groups "Prototype & script.aculo.us" group.
> > >>> To post to this group, send email to 
> > >>> prototype-scriptaculous@googlegroups.com.
> > >>> To unsubscribe from this group, send email to 
> > >>> prototype-scriptaculous+unsubscr...@googlegroups.com.
> > >>> For more options, visit this group 
> > >>> athttp://groups.google.com/group/prototype-scriptaculous?hl=en.
>
> > >> --
> > >> You received this message because you are subscribed to the Google 
> > >> Groups "Prototype & script.aculo.us" group.
> > >> To post to this group, send email to 
> > >> prototype-scriptaculous@googlegroups.com.
> > >> To unsubscribe from this group, send email to 
> > >> prototype-scriptaculous+unsubscr...@googlegroups.com.
> > >> For more options, visit this group 
> > >> athttp://groups.google.com/group/prototype-scriptaculous?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups 
> > > "Prototype & script.aculo.us" group.
> > > To post to this group, send email to 
> > > prototype-scriptaculous@googlegroups.com.
> > > To unsubscribe from this group, send email to 
> > > prototype-scriptaculous+unsubscr...@googlegroups.com.
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to