我正在创建一个Comment-Reply类似于 stackoverflow 的系统,我想知道如何使用 JSF + jQuery 来实现它。我有一个数据表,每一行都有一个链接和一个文本框,一旦我单击一个链接,只会出现同一行的文本框,并将焦点放在该文本框上。
<h:form id="userComment">
<p:dataTable value="bean.comments">
<p:column>
<!-- link that if u click on it, the textbox below appear -->
<h:inputTextarea id="reply" />
</p:column>
</p:dataTable>
</h:form>
我的主要障碍是,普通的 jQuery 用户会这样做:假设链接id是foo然后
$('#foo').click(function(){
//Make the box with id `reply` appear and put focus on it
});
但是由于每一行都有一个文本框调用reply,所以前面会有 prependIdreply和foo这样的userComment:1:fooor userComment:1:reply。因此$('#foo')并且$('#reply')不会工作