I'm using JQuery template for the data for my table... and the CSS recognizes the table rows inside the query template script and styles them how I want... but for some reason I can't call a $().click on those same rows using the same identifier. Here's the table code:
<script id="donorTemplate" type="text/x-jquery-tmpl">
<tr id="indexTR">
<td>${Person.LastName}, ${Person.FirstName}</td>
<td>${Address.Address1}</td>
<td>${PhoneContact.PhoneNumber}</td>
<td>${EmailContact.EmailContactx}</td>
<td>${Company.CompanyName}</td>
<td><a href="/Donation/Index?id=${Person.PersonID}">Add Donation</a></td>
<td> <a href="/Person/Edit?id=${Person.PersonID}">Edit</a> <a href="/Person/Delete?
id=${Person.PersonID}">Delete</a>
<input type="hidden" id="hiddenField" value="${Person.PersonID}"/>
</td>
</tr>
</script>
<div id="searchresults">
<table id="donor-list">
<thead>
<tr>
<th id="f" width="150">Name: </th>
<th width="180">Address: </th>
<th width="85">Phone: </th>
<th width="150">Email: </th>
<th width="100">Company: </th>
<th width="100"></th>
<th id="l" width="100"></th>
</tr>
</thead>
<tbody id="tableBody">
</tbody>
</table>
And the JQuery....
$("#donorSearch").submit(function (event) {
event.preventDefault();
var form = $(this);
$.getJSON(form.attr("action"), form.serialize(), function (data) {
$("#tableBody #indexTR").remove();
$("#donorTemplate").tmpl(data).appendTo("#tableBody");
});
});
That's all dandy... but this doesn't work:
$("#indexTR").click(function () {
alert('test');
});
This is what I'm trying to do on a TR click:
var val = $("#hiddenField").val();
var personID = parseInt(val);
location.href = "/Person/Details?id=" + personID;
which worked before until I switched over to the JQuery template. Any suggestions? Thanks!
indexTRid?