I'm having trouble getting a datatable (http://datatables.net/) to work in a simple jquery dialog box. When I click a button to open the box, you can see the datatable for about a second and then it immediately closes. Any thoughts would be extremely appreciative.
My function to launch the dialog box is shown below. Within it, the datatable is initialized.
function launchLocDialog(mydiv) {
alert(mydiv);
var oTable;
var giRedraw = false;
$(document).ready(function() {
$("#table_id tbody").click(function(event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
});
oTable = $('#table_id').dataTable( {
"aaData": [ /* Reduced data set */
[ "1", "02/22/12"],
[ "2", "02/22/12"],
[ "3", "02/22/12"],
[ "4", "02/22/12"],
[ "5", "02/22/12"],
[ "6", "02/22/12"],
[ "7", "02/22/12"],
[ "8", "02/22/12"],
[ "9", "02/22/12"],
[ "10", "02/22/12"],
[ "11", "02/22/12"],
[ "12", "02/22/12"],
],
"aoColumns": [
{ "sTitle": "Number" },
{ "sTitle": "Date Start" }
]
});
oTable.$('td').click( function () {
//var anSelected = fnGetSelected(oTable);
var sData = oTable.fnGetData(0,0);
//alert( 'The cell clicked on had the value of '+sData );
alert(sData);
//$.post('intsum.php', {intsumID: sData});
// window.location = "intsum.php";
});
});
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog" ).dialog({
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
}