Javascript Array Source: Using HTML tags?
Javascript Array Source: Using HTML tags?
Hello all, I am using a 2d array of strings for my data source and I am trying to add a few html tags to some of the columns. However the html seems to be ignored and the tags are just added as plain text to the table. For example:
[code]
$('#listTable').html( '' );
$('#example').dataTable( {
"aaData": [
["Testing", "Table", "1"],
["Test", "The", "table"]
],
"aoColumnDefs":
[
{ "aTargets": [ 0 ], "sType": "html", "sTitle": "First"},
{ "aTargets": [ 1 ], "sTitle": "Second"},
{ "aTargets": [ 2 ], "sTitle": "Third"},
]
} );
} );
[/code]
I want Testing to be boldface and Test to be a link to google.com. However in the table the tags just appear as plain text. Is what I want possible?
Thanks,
Stephen
[code]
$('#listTable').html( '' );
$('#example').dataTable( {
"aaData": [
["Testing", "Table", "1"],
["Test", "The", "table"]
],
"aoColumnDefs":
[
{ "aTargets": [ 0 ], "sType": "html", "sTitle": "First"},
{ "aTargets": [ 1 ], "sTitle": "Second"},
{ "aTargets": [ 2 ], "sTitle": "Third"},
]
} );
} );
[/code]
I want Testing to be boldface and Test to be a link to google.com. However in the table the tags just appear as plain text. Is what I want possible?
Thanks,
Stephen
This discussion has been closed.
Replies
[code]
"Test"
[/code]
is not a valid Javascript string. In fact it will cause a syntax error, since there are two strings with www.google.com in-between them.
Escape the "inner" quotes:
[code]
"Test"
[/code]
Allan