“Fun” with Prototype and IE7 and Tables
Its a known fact that DOM manipulation on TABLE in IE is a mine field. I thought I could get lucky with prototype when it comes to creating DOM elements on the fly. But apparently not! In particular html TABLES. So here are some of the "gotcha" moments I've had!
-
Every table needs a body
var table = Builder.node("table", [Builder.node("tr", [Builder.node("td")])]);This piece of code will render a nice table on Firefox and Safari. But unfortunately not on IE. You need to create a TBODY explicitly for IE to make sense out of this. So you need something like
var table = Builder.node("table", [Builder.node("tbody", [Builder.node("tr", [Builder.node("td")])])]);for this to work. -
Table with inline style attribute will break your javascript
var table = Builder.node("table", [Builder.node("tbody", [Builder.node("tr", [Builder.node("td" , {style:"background:blue;"})])])]);Again this piece of code will create a table with the single cell and the background is set to blue. Works like a charm in Firefox and Safari. But not IE7! This also applies to styles applied to table rows, columns and table headers. Only way around is to define a className attribute and assign a class name or set styles directly onto the DOM element like
object.style.background="blue";
Another very very annoying thing with prototype is that it does not have any error reporting mechanism. So the issues like these are harder to track down.
About this entry
You’re currently reading ““Fun” with Prototype and IE7 and Tables,” an entry on SlackCoders.com
- Published:
- 05.13.08 / 12am
- Category:
- JavaScript
6 Comments
Jump to comment form | comments rss [?] | trackback uri [?]