I'm trying to load html content into visjs timeline and using qtip2 to display a tooltip when a hyperlink inside a timeline is clicked. This tooltip needs to display html content, so it has "" in it, which causes a problem when its inserted into a title="". Normally i would be able to use a single quote in the title='<-html - content->' so it should be able to handle the quotes. But now i'm facing a problem, because i'm trying to do this from inside javascript which already uses a single quote from the javascript itself.
if i want to add a item to visjs timeline, i need to insert new items to the timeline like this.
{id: <?php echo $key; ?>, group: <?php echo $aspects['group'][$key]; ?>, content: '<a title="<?php if(isset($aspects['interpretation'][$key])): echo $aspects['interpretation'][$key]; endif;?>" role="button"><?php echo $aspects['symbols'][$key]; ?></a>', start: new Date(<?php echo $aspects['dates']['start'][$key]['year']; ?>, <?php echo $aspects['dates']['start'][$key]['month'] - 1;?>, <?php echo $aspects['dates']['start'][$key]['day'];?>, <?php echo $aspects['dates']['start'][$key]['hour'];?>, <?php echo $aspects['dates']['start'][$key]['min'];?>), end: new Date(<?php echo $aspects['dates']['end'][$key]['year']; ?>,<?php echo $aspects['dates']['end'][$key]['month'] - 1; ?>, <?php echo $aspects['dates']['end'][$key]['day']; ?>, <?php echo $aspects['dates']['end'][$key]['hour']; ?>, <?php echo $aspects['dates']['end'][$key]['min']; ?> ) },
But as you can see, content:' href etc ' already uses a single quote. So how can i escape this html quotes so it doesn't cause a conflict? I tried things like title = \" \" in the href, but i am not finding any solution yet to solve my problem.
You should use htmlspecialchars before outputting your PHP variables.