php - Managing quotes when using CKEditor setData function

860

I want to print a table in PHP, each row has a button to load it's content (HTML codes) into the CKEditor instance.

 $column = '<td><a href="#" onclick="CKEDITOR.instances.editor.setData(' . "'" . $HTMLcode . "');" . '">Load</a></td>';
 echo $column;

The HTML code also contains quotes because of the CSS styles:

<p style='text-align: center;'>

I had this result, obviously it breaks the code:

<a href="#" onclick="CKEDITOR.instances.editor.setData('<p style='text-align: center;'>Great.</p>');">Load</a> 

Any workaround for this? Any help would be appreciated! Thanks in advance, Daniel.

705

Answer

Solution:

All you have to do is escape the quote characters in the string that you pass to the setData function.

People are also looking for solutions to the problem: spl autoload register - What's the principle of autoloading in PHP?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.