I am trying to display HTML Data that comes from the database into my CKEDITOR, the problem is when i try to use setData to insert the html it gives me the following error:
Uncaught SyntaxError: Invalid or unexpected token
HTML:
<label for="descricao">Descrição</label>
<textarea id="description" name="description" class="form-control descricao_anunciante" placeholder="(quem és, o que fazes ou o que representas, temas e tipos de eventos)"></textarea>
<script>
$(document).ready(function() {
CKEDITOR.replace('description', {
customConfig: './js/wysiwygconfig.js'
});
CKEDITOR.instances["description"].setData("{!! $evento->description !!}");
});
</script>
but if try to insert the data mannualy it works:
CKEDITOR.instances["description"].setData("<p> Hello World </p>");
The data that is coming from the database:
<p>N TEM</p>
<script>
$(document).ready(function() {
CKEDITOR.replace('description', {
customConfig: './js/wysiwygconfig.js'
});
CKEDITOR.instances["description"].setData("{{ $evento->description }}");
});
</script>
Or
instead of CKEDITOR.instances["description"].setData("{{ $evento->description }}");
you can use
<textarea id="description" name="description" class="form-control descricao_anunciante" placeholder="(quem és, o que fazes ou o que representas, temas e tipos de eventos)">
{{ $evento->description }}
</textarea>
This can help because "{{ }}"- this return string with htmlentities function.