views:

842

answers:

1

I'm having problems using a table inside a ContentPane. It seems to work fine in Firefox but is invisible in Internet Explorer 7. The html below demonstrates what I mean. In Firefox you get:

Before Table
This is the table
After Table

In Internet Explorer 7 you get:

Before Table
After Table

No table at all. Does anyone know the cause of this problem?

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://o.aolcdn.com/dojo/1.3.2/dojo/resources/dojo.css" />
<link rel="stylesheet" type="text/css" href="http://o.aolcdn.com/dojo/1.3.2/dijit/themes/tundra/tundra.css" />
<script djConfig="parseOnLoad:true" type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.2/dojo/dojo.xd.js"&gt;
</script>
<script type="text/javascript">
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.form.Form");
dojo.addOnLoad(initialize);
function initialize() {
    var contentPane = new dijit.layout.ContentPane({});
 contentPane.domNode.appendChild(document.createTextNode("Before Table"));
 var table = document.createElement("table");
 var tr = document.createElement("tr");
 var td = document.createElement("td");
 td.appendChild(document.createTextNode("This is the table"));
 tr.appendChild(td);
 table.appendChild(tr);
 contentPane.domNode.appendChild(table);
 contentPane.domNode.appendChild(document.createTextNode("After Table"));
 dojo.place(contentPane.domNode, dojo.body(), "first");
}
</script>
</head>
<body class="tundra"></body>
</html>
+2  A: 

I found the problem. When creating a table programmatically, you need to make sure you place a tbody node inside the table node (and the tr nodes within that). The following works:

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://o.aolcdn.com/dojo/1.3.2/dojo/resources/dojo.css" />
<link rel="stylesheet" type="text/css" href="http://o.aolcdn.com/dojo/1.3.2/dijit/themes/tundra/tundra.css" />
<script djConfig="parseOnLoad:true" type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.2/dojo/dojo.xd.js"&gt;
</script>
<script type="text/javascript">
dojo.require("dijit.layout.ContentPane");
dojo.addOnLoad(initialize);
function initialize() {
    var contentPane = new dijit.layout.ContentPane({});
    contentPane.domNode.appendChild(document.createTextNode("Before Table"));
    var table = document.createElement("table");
    var tbody = document.createElement("tbody");
    var tr = document.createElement("tr");
    var td = document.createElement("td");
    td.appendChild(document.createTextNode("This is the table"));
    tr.appendChild(td);
    tbody.appendChild(tr);
    table.appendChild(tbody);
    contentPane.domNode.appendChild(table);
    contentPane.domNode.appendChild(document.createTextNode("After Table"));
    dojo.place(contentPane.domNode, dojo.body(), "first");
}
</script>
</head>
<body class="tundra"></body>
</html>