How do I build a function that creates my table, then returns it?
How do I build a function that creates my table, then returns it?
Folks,
This is probably a more general jQuery question, something I am still learning. But I want to abstract my datatable creation a bit. So I created a separate js function, to which I pass my data, css name, etc. It creates the table, then I want to pass back that table. Reason for that, is so that I can perform work against it later (like filter calls, etc). However I just cannot with JS get it done, any experts?
So far its something like
[code]
function createTable(data, columns, css)
{
var oTable;
$function()
{
var tablecss = $(css);
oTable = tableCss.dataTable(
{
// datatable stuff
});
}
return oTable;
}
[/code]
However oTable is always undefined. Is there a way to perform a callback?
This is probably a more general jQuery question, something I am still learning. But I want to abstract my datatable creation a bit. So I created a separate js function, to which I pass my data, css name, etc. It creates the table, then I want to pass back that table. Reason for that, is so that I can perform work against it later (like filter calls, etc). However I just cannot with JS get it done, any experts?
So far its something like
[code]
function createTable(data, columns, css)
{
var oTable;
$function()
{
var tablecss = $(css);
oTable = tableCss.dataTable(
{
// datatable stuff
});
}
return oTable;
}
[/code]
However oTable is always undefined. Is there a way to perform a callback?
This discussion has been closed.