I have created this simple visualforce page, using google charts. Everything works great until there is a comment in the rating with an apostrophe ('). I have tried using the JSENCODE, but it is still not working - any suggestions?
The below works fine with no apostrophes - but renders nothing when there is one. (in the child2.Rating_Type__c
field.
<apex:page standardController="Account" showheader="false">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['table']});
</script>
<script type="text/javascript">
function drawVisualization2() {
// Create and populate the data table.
var data2 = google.visualization.arrayToDataTable([
['Contact Name', 'Date', 'Rating Type', 'Rating', 'Comments', 'Rating Status'],
<apex:repeat value="{!Account.Product_Ratings__r}" var="child2">
['<a href="http://na13.salesforce.com/{!child2.id}"> {!child2.Contact_Name_Text__c}</a>',
'{!child2.Date__c}','{!child2.Rating_Type__c}',
'{!child2.Rating__c}', '{!JSENCODE(child2.Comments__c)}',
'{child2.Reference_Status_stoplight__c}'],
</apex:repeat>
]);
// Create and draw the visualization.
visualization = new google.visualization.Table(document.getElementById('ratings'));
visualization.draw(data2,{allowHtml: true, page: 'enable', pageSize: '25'});
}
google.setOnLoadCallback(drawVisualization2);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="ratings"></div>
</body>
</apex:page>