How can I write common function to initialize datatable on tables spread across multiple pages?

How can I write common function to initialize datatable on tables spread across multiple pages?

abhish3kkabhish3kk Posts: 1Questions: 1Answers: 0
edited April 2016 in Free community support

I am using Datatables on multiple pages and now want to optimize my code. Currently, I am writing $('#tableId').Datatble({datatable options}) on every view. Is there anyway by which I can make a common function by passing settings as arguments to initialize tables.

Something like

initializeDatatable(datatable options, tableId);

`function initializeDatatable(){

}`

This discussion has been closed.