0

I'm building application using pop-ups. I'm getting new information with Ajax in the main page and updating the popup page. In the side window (pop-up) I've got a table and when new data is received I'm just adding row in this table. In FF, Chrome and Opera that is working pretty well but when I try to append child (no matter if I'm using jquery or not) IE gives me a Unspecified error. I'm trying to append the child directly to the table like that:

var tableHeader = this.config.newResultsWindow.document.getElementById('newResultsTableHeader');
tableHeader.appendChild(newRow);

When I'm using just innerHTML (for example this.config.newResultsWindow.document.body.innerHTML = updatedTable) everything is OK but the table's content is very big and I cant write it all every time.

What can I do?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • 1
    What's the type of the `'#newResultsTableHeader'` element? Table? – Šime Vidas Nov 09 '11 at 22:09
  • Provide a debuggable testcase please.... – Lightness Races in Orbit Nov 09 '11 at 22:12
  • //It's thead element. This is how I'm creating the row: buildTableRow: function (data) { var row = '', width; for (var child in data) { row += '' + data[child] + ''; } row += ''; return $(row); }, //And appending it: newRes.parentNode.insertBefore(row[0], newRes.nextSibling ); //Here the newRes is a thead element. –  Nov 10 '11 at 08:11

3 Answers3

1

Found something that worked for me. Try appending the HTML inside of the newRow variable:

tableHeader.appendChild(newRow.html());
Dan-Nolan
  • 6,594
  • 4
  • 27
  • 32
1

have you tried catching the error, it might tell you more than 'Unspecified':

try {
    tableHeader.appendChild(newRow);
} catch(error) {
    alert(error);
}

I hope it helps, Rob

robertp
  • 3,557
  • 1
  • 20
  • 13
1

IE doesn't allow the moving of nodes between different document's , so a node created in document A cannot be inserted to document B

Dr.Molle
  • 116,463
  • 16
  • 195
  • 201
  • Does IE support `document.adoptNode`? https://developer.mozilla.org/en/DOM/document.adoptNode ... it's DOM Level 3 so I assume not. – Felix Kling Nov 09 '11 at 22:29
  • Is there an alternative for that in previous IE versions? –  Nov 10 '11 at 05:56
  • Yes, there is an easy way that works in all browsers. When creating the row using `$(row)` provide as 2nd argument to $ the document-object of the popup-window, so the row will be created by the popup-document and you don't have issues with different documents. See the fiddle **http://jsfiddle.net/doktormolle/J9KLL/** (it uses an iframe instead of a popup, but it's the same problem with different documents) – Dr.Molle Nov 10 '11 at 12:37