0
I need to create a link where I have the input name in the table using Datatables, this link should call a javascript function. The problem is that when the table is loaded it executes the script for each table row, as if all links were being clicked.
<script>
$(function () {
$("#insumos").dataTable({
"bServerSide": true,
"sAjaxSource": "/Insumo/BuscarInsumosDataTable",
"bProcessing": true,
"language": {
"url": "/DataTables/Traducao"
},
"aoColumns":
[
{
"sName": "InsumoId",
"mData": "InsumoId"
},
{
"sName": "Nome",
"mData": "Nome",
"render": function ( data, type, full, meta ) {
return '<a href="onclick=' + selecionarInsumo(data) + '">' + data + '</a>';
}
}
]
});
})
function selecionarInsumo(nome) {
alert("deu certo, " + nome)
}
</script>
Hello. Can you make an example in jsfiddle? It’s much easier to help.
– Tiago Gomes
Tiago, ta lá, https://jsfiddle.net/Alan_Almeida/exoe3qwc/13/ I commented some lines because they are from my server’s resources, and with them it was not working.
– Alan Almeida