Calling jquery function on a embedded jsp table

Calling jquery function on a embedded jsp table

I am adding jquery tablesorter  plugin to my j2ee application. Currently, I have one main JSP page and based on a condition, it will toggle (show/hide)  embedded another jsp page. This embedded JSP page has a table on which I want to add tablesorter plugin. This toggle feature is being implemented using using css and ajax. Here is how I have this now:

In JSP page:

<a id="la<%=i%>" href="javascript:toggle_detail('a<%=i%>','false')">

<img id="ia<%=i%>" src="../resources/plus.gif" border="0""><span style="font-size: 13px; color: #336699">Show Detail</span>

</a></div>

<div id="a<%=i%>" class="report_detail" style="display: none;">

JS function:

function toggle_detail(id, removal)

{

if (el.style.display == 'none' ) {

.........

var req = getXMLHttpRequest();
if (req != null) {
  req.open("GET", "showperson.jsp?rand=" + randomnumber + "&id=" + ID, true);
 }

............

}

Now, for tablesorter I am simply using below code which is working if I have table on main page 

< script >

$( function (){

$( "#sortedTable" ).tablesorter()

});

</ script >

It is not working for embedded jsp page. Please advise, how I should use this plugin for embedded table.


I appreciate your help.

Thanks