Get Row Data and Pass to my JavaScript Function
Get Row Data and Pass to my JavaScript Function
zezu
Posts: 2Questions: 1Answers: 0
I am adding a view/Edit Button to each row of my table , On click i have to get the data and pass it to my javascript function , but unable to do so ,
Adding the button/links like this
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent":
'<a id="btn-view">View-</a>'
+ '<a class="btn-edit">Edit</a>'
} ]
$('#allMemberTable tbody').on('click', '.btn-edit', function (e) {
var data = table.row( $(this).parents('tr') ).data();
console.log("data ="+data[0]);
// Getting Row data scuccessfully
test(data) ; // This is not getting called , it is not recognizing this metod , giving error , test is not a function , i tried with this.test() , but same
});
// Getting Row data scuccessfully
test(data) ; // This is not getting called , it is not recognizing this metod , giving error , test is not a function , i tried with this.test() , but same
please correct me or give any other way around ( sorry for this basic question)
EDIT: Reformatted post using Markdown
This discussion has been closed.
Answers
Its hard to tell with your snippets of code. Where do you have your
test
function?Kevin
Agreed - it looks like you simply don't have a
test
function in that scope.Allan
These are two methods in one angular2 class , I call setTableData to set the table data, and from that method i want to call other method e.g. test(data).
I still don't see a valid function called
test
anywhere. This code isn't actually valid Javascript:Can you link to a test case showing the issue please?
Allan