{% for editor in editors %}
<div id="{{editor.ck_id}}" name="{{editor.ck_id}}">
</div>
{% endfor %}
<script>
{% for editor in editors %}
CKEDITOR.appendTo("{{editor.ck_id}}" ,
{
on: {
blur: function(event){
var data = event.editor.getData();
console.log("data of {{editor.ck_id}} is " + data);
var request = $.ajax({
url: "/editor/save/",
type: "GET",
data: {
content : data,
content_id : "{{editor.ck_id}}"
},
dataType: "html"
});
}
}
},
"{{editor.data}}"
);
{% endfor %}
from django.db import models
class ckeditor(models.Model):
ck_id = models.CharField(max_length=100,null=False,blank=False)
data = models.TextField(null=True,blank=True)
Tony Stark
is Iron man.
def save(request):
if request.method == 'GET':
editor_data = request.GET['content']
editor_id = request.GET['content_id']
print "data received"
print "editor data is %s" %(editor_data)
print "editor id is %s" %(editor_id)
else:
print "No Data received"
editor = ckeditor.objects.get(ck_id=editor_id)
editor.data = editor_data
editor.save()
One can see now that since it was a text field it has filled some '\n' tags in between.
Now When I re start the server and set the data of every ck-editor instance again then this exception is raised -
Uncaught SyntaxError: Unexpected token ILLEGAL
This happened because the text(editor's data) which I sent got converted into illegal tokens.Do I need to convert text which I am sending into valid html or do I need to encode/decode that text?
Now my question is how to go about this complete procedure of fetching editor's data,storing it in database and then again reset data on restarting server. I have posted this question on several forums but many people have got no clue of what I am asking?
CK-EDITOR team has proudly mentioned that their community has been shifted to SO but I have got no replies from them either. I guess they only give support when user buys their license which costs 299$.
Can anybody please help me out in this? I am literally lost all hopes.I am getting no help for last 1 week and probably I will get some help this time around.
Thanks.