How to make some validations before going on a hyperlink.
How to make some validations before going on a hyperlink.
radu.cruceana
Posts: 6Questions: 1Answers: 0
Hello dear friends,
I have the following datatable:
$('#tabelOferte').DataTable({
"lengthMenu": [[10, 25, -1], [10, 25, "All"]],
"aaSorting": [[0,'desc'], [0,'desc']],
processing: true,
serverSide: true,
ajax: {
"url": 'ajaxTabelOferte',
"type": "GET",
},
columns: [
{data:'id', name:'id', "visible": false, "bSearchable": false },
{data: 'number' ,name: 'numar'},
{data: 'actions', name: 'Actions', "bSearchable": false,
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).html("<a href=edit/"+oData.id+">" + "<Edit>" + </a>"+
" "+
"<a href=print/"+oData.id+">" + "Print" + "</a>"
)
},
}
],
});
In the last column there are 2 links.
I want if the user click on the fist link (Edit) to first launch a java script function to make some validations and only if validations are OK to get the link.
It would be OK to put the links in separate cells if this could make the solution easier.
How do I insert the call for the java script function?
Thank you for your time!
This discussion has been closed.
Answers
Hi @radu.cruceana ,
The easiest way would be to not use links, but just a
click
event on that cell, see an example here. You could use CSS styling to give it the appearance of a link if that's important for your app.Hope that helps,
Cheers,
Colin