Merge Inicialization and Funtions
Merge Inicialization and Funtions
kotusha
Posts: 3Questions: 1Answers: 0
I have two scripts that u need two merge for inicialization, and my third script is a click function, I can not get them two work property in one script. Please help me. Thank you.
Script 1
$(document).ready(function() { $('#TableRecords').DataTable( { "language": { "lengthMenu": "Despliega _MENU_ registros por pagina", "zeroRecords": "Ningun registro fue encontrado", "info": "Mostrando pagina _PAGE_ de _PAGES_", "infoEmpty": "Ningun Registro Disponible", "infoFiltered": "(Filtrado de _MAX_ registros totales)", "loadingRecords": "Cargando...", "processing": "Procesando...", "search": "Busqueda:", "paginate": { "first": "Primero", "last": "Ultimo", "next": "Siguiente", "previous": "Anterior" } } } ); } );Script 2
$(document).ready(function() { $('#TableRecords').DataTable( { "columnDefs": [ { "targets": [ 1 ], "visible": false, "searchable": false }, { "targets": [ 2 ], "visible": false } ] } ); } );Script 3
$(document).ready(function() { var table = $('#TableRecords').DataTable(); $('#TableRecords tbody').on('click', 'tr', function () { var data = table.row( this ).data(); document.getElementsByName("OriDes_ID")[0].value = data[0]; document.getElementsByName("OriDes_Ciudad")[0].value = data[2]; } ); } );This discussion has been closed.
Answers
You should initialise a DataTable only once. See the options section of the manual for an example on how you can merge multiple configuration objects.
Allan
I try to merge them like this but it did not work, can someone help me?
Thank you
$(document).ready(function() { $('#TableRecords').DataTable( {
"language": {
"lengthMenu": "Despliega MENU registros por pagina",
"zeroRecords": "Ningun registro fue encontrado",
"info": "Mostrando pagina PAGE de PAGES",
"infoEmpty": "Ningun Registro Disponible",
"infoFiltered": "(Filtrado de MAX registros totales)",
"loadingRecords": "Cargando...",
"processing": "Procesando...",
"search": "Busqueda:",
"paginate": {
"first": "Primero",
"last": "Ultimo",
"next": "Siguiente",
"previous": "Anterior"
},
"columnDefs": [
{
"targets": [ 1 ],
"visible": false,
"searchable": false
},
{
"targets": [ 2 ],
"visible": false
}
]
}
} );
} );
If you apply the proper syntax highlighting for your code, I can try and help... The instructions for them are right below the Reply/Comment input text area...
This is what does not work
I also want to add this, all in the same script if possible: