escaping grid data

I load my grid from xml I wrap text in cdata

For example

gridData = ‘’



When I load grid I use

mygrid_#{group.id}.parse(gridData);



This code fails because of special char ’ . How do I handle javascript special char? The following doesn’t seem to work.

mygrid_#{group.id}.parse(encodeURIComponent(gridData));

How do I handle javascript special char?
The char is not really special , it just breaks the data setting line

Will not work
gridData = ''

Will work
gridData =