Sortable Table when table is built with agent via AJAX call (using SortableTable script)

I am building a table in an agent and returning it to the browser. I have reviewed the returned html and verfied that it is in the correct format. Next I am appending the code below and using it as the innerHTML of a div. What I am finding is that the columns are not sortable. It appears as if the class sort-table is not being applied to the column. The graphics are not added to the header cells, and they are not click-sortable. If I build the table html by hand on the form, it works fine. Has anyone had experience with this? Help would be greatly appreciated.

This code is in the callback function and I have verified that the table id is spelled the same as it is listed in the function:

var jscriptdata = ‘’

$(“tableoutput”).innerHTML = req.responseText + jscriptdata;

Subject: Sortable Table when table is built with agent via AJAX call.

Writing {script} tags within innerHTML won’t work. What I’d do in this scenario is build a JS function and place it in the HEAD of your form. Then, after you write req.responseText to the innerHTML of your div, call that function and pass it the id of the table you just dynamically created. Maybe something like this:

function buildSortableTable( id ) {

var el = document.getElementById( id );

var st = new SortableTable( el, [“CaseInsensitiveString”, “CaseInsensitiveString”, “USCurrency”, “Date”, “Number”, “Number”, “Number”]);

st.sort( 1, false, “Nothing” );

}

HTH

Patrick

Subject: RE: Sortable Table when table is built with agent via AJAX call.

That makes perfect sense, and works just the same. Thanks.