I need to create a link where I have the input name in the table using the DataTables, this link should call a javascript function. The problem is that when the table is loaded it runs the script for each row of the table, as if all the 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>