[jQuery] Stumped on Tables
I've tracked down my issue with using $.append() for table rows.
First, jQuery is converting any string into a document node by
creating a div and setting it's HTML. This has a side-effect of
striping the first TR within the string in IE, and of striping ALL
table tags in Firefox.
I have a work around in mind, but am having trouble coming up with
the code. My idea was to first convert my string into a document
fragment, traverse it, and append the row correctly to the table when
a TBODY was found in the parent chain.
Something like:
$(el).parents().each(function(){
if ($(this).is('tbody')) {
// do magic
}
});
I was attempting to convert the string into parsed XML, but am having
troubles traversing the parsed XML. My first attempt:
function xmlnode_to_html(node) {
var el = document.createElement(node.tagName);
if (node.attributes) el.id = node.getAttribute('id');
if(node.childNodes.length > 0) {
for(i=0;i<node.childNodes.length;i++) {
if (node.tagName) el.appendChild(node_to_table(node.childNodes
[i]));
}
}
return el;
}
results in a varying degree of errors depending on browser.
Is my approach completely off? Does anyone have a better idea?
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/