I'm looking for a way to be able to use a function (in this case .Datatable()
) in two id
different ones ( $("#ejemplo1")
and $("#ejemplo2")
) without having to repeat the code.
- Example:
$("#ejemplo1").DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"autoWidth": true,
"language": idioma
});
$("#ejemplo2").DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"autoWidth": true,
"language": idioma
});
Is there a possible way without having to call the function DataTables()
more than once?
The idea of the id is that they are unique. You can assign a class to all the tables you want to initialize in the same way and then
I would initialize them all with that configuration.
If the options are always the same, you could create a function to which you pass the id of each of the datatables that you want to fill:
Then you could enter all the ids in an array and go through it: