...

View Full Version : DHTML table content stylesheet not refreshed



mikeismike
12-08-2005, 03:12 AM
I'm having a little trouble with internet explorer. When adding table rows to tables via javascript, stylesheet class attributes do not render at all.

I've looked into the table.refresh() command for IE, but it does not apply the style.

I know it's not a stylesheet issue because if I place the same table declaration on the page statically right below the table that is dynamically added, the static table renders it's CSS properly while the dynamic table (which has an identical structure and content) does not render properly.

Ideas?

ronaldb66
12-08-2005, 09:28 AM
Care to supply a link to said page?
It sounds like the styles aren't re-rendered when you dynamically add table-related elements. Just for good measure, try if it works for regular elements like paragraphs; if not, I'm afraid you'll have to come up with another solution.

mikeismike
12-08-2005, 02:32 PM
I'll work on getting the styles for <p> tags and see if that helps. It's not so much the styles, but only when I apply the style via class="" for the DHTML elements.

mikeismike
12-08-2005, 04:58 PM
OK figured this one out.

I was using a method to import an xml string into a dom object. I've included hte original method here:




importNode: function(domDocument, node) {
switch (node.nodeType) {
case 1:
var element = domDocument.createElement(node.nodeName);
for (var i = 0; i < node.attributes.length; i++) {
element.setAttribute(node.attributes[i].nodeName, node.attributes[i].nodeValue);
}
for (var i = 0; i < node.childNodes.length; i++)
element.appendChild(oplib.importNode(domDocument, node.childNodes[i]));
return element;
break;
case 3:
var textNode = domDocument.createTextNode(node.nodeValue);
return textNode;
break;
/* add other nodes here */
}
}


I've found that you can't add set the class attribute via Javascript with setAttribute in Internet Explorer. The following code resolved my issue.



importNode: function(domDocument, node) {
switch (node.nodeType) {
case 1:
var element = domDocument.createElement(node.nodeName);
for (var i = 0; i < node.attributes.length; i++) {
if (node.attributes[i].nodeName == 'class') {
element.className = node.attributes[i].nodeValue;
}
else {
element.setAttribute(node.attributes[i].nodeName, node.attributes[i].nodeValue);
}
}
for (var i = 0; i < node.childNodes.length; i++)
element.appendChild(oplib.importNode(domDocument, node.childNodes[i]));
return element;
break;
case 3:
var textNode = domDocument.createTextNode(node.nodeValue);
return textNode;
break;
/* add other nodes here */
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum