JQuery - add onclick to TR
I use Richfaces and one of rich: dataTable generates this html:
<form id="scheduleForm">
<table id="scheduleForm:rowList">
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</form>
I want to act by clicking on TR for this table. How can i do this? The following also works for other tables on the page, and I get alert () for other rows, and I don't want this.
jQuery('#scheduleForm:rowList tr').click(function(event) {
alert(1);
});
O ':' char. It is created by Richfaces.
Source:
<h:form id="scheduleForm">
<rich:dataTable id="rowList">
</rich:dataTable>
</h:form>
+3
7 answers
I know that :JSF / RichFaces is being created. I used to have problems with :. This is probably not what jQuery people in ID expected. They use it for selectors. What you can do is:
jQuery('table[id = "scheduleForm:rowList"] tr').click(...)
Check out http://jee-bpel-soa.blogspot.com/2009/04/tips-and-tricks-on-jquery-and-richfaces.html
+2