0

I am currently trying to display links in the pivottablejs cells. I reused the function from this SO answer. Here is a working snippet without using hrefs in the a tag.

<div id="output" style="display: none;">,id,link
0,1,<a>Google</a>
0,2,<a>Google link</a>
</div>

But when I add double quotes or single quotes to be able to generate a real link:

<div id="output" style="display: none;">,id,link
0,1,<a href="www.google.com">Google</a>
0,2,<a href="www.google.com">Google link</a>
</div>

the $.csv.toArrays function complains with a Uncaught Error: CSVDataError: Illegal Quote error. How can I avoid the quote error? I am currently stuck and not sure how to resolve this issue. I am a beginner in javascript. Thanks for any pointers and suggestions.

Blind0ne
  • 1,015
  • 12
  • 28

1 Answers1

0

I figured out what the problem was. Before passing the table string into $.csv.toArrays function I needed to get rid of the double quotes from the table:

<div id="output" style="display: none;">,id,link
0,1,<a href=https://www.google.com>Google</a>
0,2,<a href=https://www.google.com>Google link</a>
</div>

and then replace the double quotes with single quotes like this:

$.csv.toArrays($("#output").html().replace(/"/g, "'"))

and then it worked and displayed the text as a hyperlink to the correct location.

Blind0ne
  • 1,015
  • 12
  • 28