views:

143

answers:

2

The DOM looks like this:

<table>
  <tr>
    <td>a</td>...<td>g</td>
  </tr>
  <tr>
    <td colspan="3">
      <table>
        ...
      </table>
    </td>
  </tr>
  <tr>
    <td></td>...<td></td>
  </tr>
</table>

Any idea why this wouldn't work in IE? I tried setting width:auto on the TD holding the inner table, and table-layout:fixed isn't viable because the tabular data is generated dynamically.

What could be going wrong?

Currently, the table only fills the first column, and it will not span.

Update: EXAMPLE

http://stefankendall.com/files/example.html

+1  A: 

The only thing that comes to mind is that you may have to fill the columns with something for them to get rendered in IE.

<td>&nbsp;</td>
Pekka
This doesn't work. Even with dummy columns, this doesn't work.
Stefan Kendall
@Stefan strange. Can you show a full example?
Pekka
I've posted a full example. I wrote all that by hand, and it was hell. The JS is a little messy, but that's the core of the issue.
Stefan Kendall
@Stefan I'm pretty sure this has to do with the way you construct the HTML. If I open the developer tools in IE8, edit a random part of the newly created table (e.g. turn `colSpan` into `colspan` and back), and apply the changes, it will render correctly. This is either a display bug in IE, or your jQuery calls are broken.
Pekka
Is `$("<td>")` a valid jQuery way of creating an element? Without the closing tag?
Pekka
@Pekka: This is how you construct new dom elements. Inspect the DOM with firebug and you will see that the </td> elements are there.
Stefan Kendall
@Stefan in Firefox, yes. In my IE 8, the DOM explorer behaves funny for the new elements (they don't show up at all at first). But if that's the way to do it, it may be fine. Strange....
Pekka
It works fine. As it turns out, "colSpan" makes it work in IE.
Stefan Kendall
@Stefan you mean changing `colSpan` to `colspan`? Did you do that in the developer tools, or did you change the jQuery?
Pekka
I changed the jQuery to set the attribute as ("colSpan",100) rather than ("colspan",100).This makes me a sad panda. jQuery should take care of this.
Stefan Kendall
@Stefan strange. Shouldn't be an issue either way (HTML properties are not case sensitive in HTML.) But if it works.....
Pekka
Someone downvoted me for the correct solution. Lovely.
Stefan Kendall
@Pekka: Since when does IE6/7/8 render HTML? It renders something like it, but not really. :)
Stefan Kendall
@Stefan yeah, but still! This is leaving me baffled.
Pekka
+4  A: 

Use colSpan, not colspan

Stefan Kendall
Who the hell downvoted this? This is the correct solution to my problem.
Stefan Kendall
Attributes should be entered in lower case.
Ken Ray
You're an idiot. This is the only way IE6/7/8 respect the attribute, at least when applied dynamically. I don't care what the hell the spec is - I need to support IE.
Stefan Kendall
@Ken Ray Just because something should be done doesn't mean the implementers did it that way. This kind of thing happens all the time in IE.
Patrick
You didn't mention it was in jQuery. JavaScript attributes and styles have always been formatted like such (i.e. backgroundImage and className). Default HTML would be "colspan" and jQuery would be "colSpan". But jQuery would convert that back to just "colspan" in the actual HTML it generates.
animuson
Addon: It appears that IE just expanded upon that. Either way is perfectly fine *within jQuery*. However, if you're just setting the colspan in HTML that gets outputted (not within JavaScript), you should always use completely lower case, because every browser will recognize it.
animuson
http://stackoverflow.com/questions/1294850/set-colspan-dynamically-with-jqueryFurthermore, jQuery is supposed to standardize and fix attributes. It looks like this was fixed in 1.4.2: http://code.jquery.com/jquery-1.4.2.jsSearch for "colspan"animuson, I don't think you understand the purpose of jQuery.
Stefan Kendall