If I have a table already inside my html file, which is sortable because its class is declared like so, it works. There is a javascript file included which defines the sortable class.

<table id="test" class="sortable">

But, if I inject the table using AJAX into a

like so:

var div = document.getElementById( "divID" );
div.innerHTML = tableText;

After injecting, the table appears but is not sortable.

I've tried doing this:

var myTable = document.getElementById( "test" );

myTable.className = "sortable";
myTable.style.className = "sortable";

If I inspect the DOM using FireFox's DOM inspector, it does show the sortable class is assigned (but it still doesn't work).

Any info or examples would be greatly appreciated (where injecting some HTML retains its class), thanks.