Reputation: 117
I am trying to add an <a> </a>
inside of my datatable where I already had o use the ""´s right after return, but how do I pass my sub into my alert call?
function (data, type, full, meta) {
var sub = full[7].substring(0,21)+"...";
return "<a class='astyle' onclick='new function() { alert('"+sub+"') }'>"+sub+"</a>";
}
My example is not working.
Upvotes: -1
Views: 32
Reputation: 167162
You have to escape the '
here:
onclick='new function() { alert(\'"+sub+"\') }'>
Full Code
function (data, type, full, meta) {
var sub = full[7].substring(0, 21) + "...";
return "<a class='astyle' onclick='new function() { alert(\'"+sub+"\') }'>"+sub+"</a>";
}
Best way to handle these would be split all the variables and get it done. Don't have one single variable with all the confusing quotes and codes.
Upvotes: 2