I've got a table in my page wrapped up in Datatables. The data is being grabbed from a php file perfectly and there is no problem with the code in that part. However, I've got a problem with buttons inside the table. The followings are the columns inside my Datatables table:
columns: [
{"data": "id"},
{"data": "name"},
{data: null, render: function(data, type, row) {
return '<a href="#" onclick="" class="buttons edit-button"><span class="fa fa-pen"></span></a>'
}},
],
As you can see, I have defined three columns, the first of which is 'id', the second 'name' and the third a column including a button. My problem is related to this button. In fact, I want to call a function, for instance, edit(), whenever this button is clicked. The edit() function gets the value of 'name' (second column) as its parameter. Now the question is this: how can I pass the value of the second column to the function edit() when the button is clicked; as a result, the onClick call of the third column shall be something like this: onclick="edit(name.val)"... I have left this onClick="" empty, because I don't know how to do this.
Millions of thanks in advance.