views:

25

answers:

2

Hi.. I think I know this is an IE bug ... I need to add new row to an HTML table at the exact position. (don't want insertRow(index) cuz this looks like gonna be better for some other reasons)

function AddNewItem(td) {   ///td comes from button at the HTML code, <input ... onclick="AddNewItem(this.parentNode)"
  var grid = GetGrid();
  var itemIndex = $(td.parentNode).attr('index');
  ///alert(itemIndex + "'e eklenecek");
  var newRow = document.createElement('tr');
      var td1 = document.createElement('td');$(td1).addClass('td');
      var td2 = document.createElement('td');$(td2).addClass('td text r');
      var td3 = document.createElement('td');$(td3).addClass('td text r');
      var td4 = document.createElement('td');$(td4).addClass('td text r');
  $(newRow).append(td1);$(newRow).append(td2);$(newRow).append(td3);$(newRow).append(td4);

  grid.insertBefore(newRow, td.parentNode); ///THIS GIVES AN INVALIDARGUMENT error .. Any solutions will be appreciated :)
}


function GetGrid() {
 var grid = document.getElementById("MasterTableView");
 return grid;
}
A: 

My guess is that td.parentNode is not a child element of grid. Take a look at the W3C specification for insertBefore to make sure that you are calling the method with valid parameters.

Chris Shouts
grid is the HTML table, and td.parentNode is the TR that belongs to that grid ..
Emre
A: 

I would guess that you're passing in an invalid argument to AddNewItem, that (in IE, at least) it's not a td element like you think.

palswim
don't worry .. it is that td like I think :)it gives the innerHTML and plus the whole thing works now
Emre