5 Mar 2011 davidw   » (Master)

Manipulating ckeditor data with jQuery

I'm working on a project that utilizes CKeditor and need to manipulate the data it contains.  Since I'm familiar with jQuery and it's fairly efficient at doing that sort of thing, rather than figuring out how CKeditor manipulates things internally, I wanted to, at least to get started, access things in jQuery.  There isn't a lot of information out there on the best way to do that.  Here's what I figured out - it seems to work pretty well:

    var editor = theeditor();
    var contents = $("<div id='specialwrapperthing'>" + editor.getData() + "</div>");

    .... hack away with jQuery ....
    editor.setData(contents.html());

Basically, you just wrap up what the editor hands you in terms of the data, hack away on it, and then put the HTML back into the editor.

Syndicated 2011-03-05 14:22:21 (Updated 2011-03-05 14:37:51) from David's Computer Stuff Journal

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!