Adam Schiavone
Adam Schiavone

Reputation: 2452

Save edited inline text from CKEditor 4 asp net

I am trying to implement CKEditor 4 into an ASP NET website that I am working on, but I cannot figure out how I would save the edited material from the inline editor I know how to do it with the the old version, but I just don't understand the process for this.

I have looked in the forums... There is not v4 forum.

I looked in for the documentation.... Couldn't find it.

I have a feeling that this is a simple task, but I just don't know how.

Upvotes: 2

Views: 7770

Answers (2)

oleq
oleq

Reputation: 15895

You can get your data with CKEDITOR.instances.editor1.getData(). Then you can send it via AJAX or store it as a value of some input field. To do this periodically, follow this method:

CKEDITOR.disableAutoInline = true;

var editor = CKEDITOR.inline( 'editable' );

var savedData, newData;
function saveEditorData() {
    setTimeout( function() {
        newData = editor.getData();

        if ( newData !== savedData ) {
            savedData = newData;

            // Send it with jQuery Ajax
            $.ajax({
                url: 'yourUrl',
                data: savedData
            });

            // Or store it anywhere...
            // ...
            // ...
        }

        saveEditorData();
    }, 500 );
};

// Start observing the data.
saveEditorData();

You can also observe the submit event and update some (hidden) form field with your data.

Have fun!

Upvotes: 5

Joel Peltonen
Joel Peltonen

Reputation: 13402

Are you trying to get it with AJAX or send with a form? The value of for example the top right inline editor area with Lorem Ipsum can be gotten like in the older version with simply

CKEDITOR.instances.editor1.getData().

In the XHTML output example they have a simple form that seems to work and I believe that using an (static) inline editor is just the same.

If you transform elements into editors inline dynamically, I would try to bind to the submit event and before submitting loop through all CKEDITOR.instances, get their data into hidden from fields. As for the hidden field naming or identifying which hidden field corresponds to which dynamic editor you'll have to figure out yourself :)

Upvotes: 1

Related Questions