I am listing information from my database in a Datatable with jQuery and until then everything is ok.
What I want to do is to click on the 'row' of Datatable
load on that div all the information of that ID that was presented in the table. An example of what I want to do is type gmail that appears the emails in list form and when the person clicks loads it.
How can I do this with a Datatable?
I'm displaying 10 items on the first page of the table, and when I click on the row, it displays the row I want. The problem is when I go to the second or third page and click on the line the JavaScript alert does not work.
$(function() {
var oTable = $("#tabelaaberto").dataTable({
"oLanguage": {
"sEmptyTable": "Nenhum registro encontrado",
"sInfo": "Exibindo de _START_ até _END_ no total de _TOTAL_ registros.",
"sInfoEmpty": "",
"sInfoFiltered": "(Filtrados de _MAX_ registros)",
"sInfoPostFix": "",
"sInfoThousands": ".",
"sLengthMenu": "_MENU_ resultados por página",
"sLoadingRecords": "Carregando...",
"sProcessing": "Processando...",
"sZeroRecords": "Nenhum registro encontrado.",
"sSearch": "Pesquisar: ",
"oPaginate": {
"sNext": "Próximo",
"sPrevious": "Anterior",
"sFirst": "Primeiro",
"sLast": "Último"
},
"oAria": {
"sSortAscending": ": Ordenar colunas de forma ascendente",
"sSortDescending": ": Ordenar colunas de forma descendente"
}
}
});
$(document).ready(function(e) {
$("#tabelaaberto tbody td").on('click',function(){
var nTr = $(this).parents('tr')[0];
var aData = oTable.fnGetData(nTr);
alert(aData[0]);
});
});
});