I am adding a row to the table using the following function:
function loadTable()
{
var index, html, tbody;
//clear the table
for (index = 0; index < content.length; index++)
{
var tbody = document.getElementById("tablei").getElementsByTagName('tbody')[0];
var row = document.createElement("TR");
row.setAttribute("id", index);
row.setAttribute("class", "selectableRow editableDiv");
var td1 = document.createElement("TD");
td1.innerHTML = content[index].Author;
var td2 = document.createElement("TD");
td2.innerHTML = content[index].AuthorType;
var td3 = document.createElement("TD");
td3.innerHTML = content[index].CosignStatus;
var td4 = document.createElement("TD");
td4.innerHTML = content[index].FileTime;
var td5 = document.createElement("TD");
td5.innerHTML = content[index].NoteTime;
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
row.appendChild(td5);
tbody.appendChild(row);
}
}
I added a jquery function to catch the clicking event on the row.
$('.selectableRow').click(function (event)
{
var id = $(this).attr('id');
var item = content[parseInt(id)];
alert(id);
}
But no alert shows up when the row is clicked.
But twhen I add the same code directly in html, the alert is called.
loadTablefunction being called before theclickfunction is set?