Hi!
I'm using this kind of code:
var element = $('<div class="wrapper"><div contenteditable="true">Stuff</div><div contenteditable="true">Stuff</div></div>'); $('#zone').append(element); element.find("[contenteditable=true]").each(function(){ CKEDITOR.inline($(this).get(0)); });
And it works. The only problem is, I need to get the contents of each editor and to be able to group together contents that are under the same wrapper.
I was going to do this by using jQuerys each for the wrappers, then just getting the IDs of the contenteditable elements and pass them to CKEDITOR.instances[$(this).attr('id')] to access their content.
But the elements don't have an ID as CKEditor didn't give them one.
Looking at the instances array reveals that there are multiple instances indeed with unique IDs, but I don't know how to access them in reverse.
Am I doing this completely wrong? How would you guys do this?
Could I use something like CKEDITOR.on( 'instanceCreated') where I manually add the id to the DOM element?
Like this:
CKEDITOR.on( 'instanceCreated', function( event ) { var editor = event.editor, element = editor.element; $(editor.element).attr("id",editor.name); });
This feels so hackish and nasty that I might have to take a shower...
I would love any input on this! Thanks!