Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8855163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:04:15+00:00 2026-06-14T14:04:15+00:00

I have an instance of CKEditor inside a Backbone View with a plugin that

  • 0

I have an instance of CKEditor inside a Backbone View with a plugin that posts whatever text is in the editor to my site on click. I want to clear the CKEditor on click as well but using setData doesn’t work. It flashes as though something is happening, but then resets to the same data that was already there.

It’s called inside the plugin like this:

note: THIS is a variable referencing the Backbone View

CKEDITOR.plugins.add( 'post', {
    init: function( editor ) {
        editor.addCommand('post', {
            exec: function(editor) {
                THIS.model.postMessageAttempt(editor.getData());
                THIS.options.data = "";
                editor.setData("");
            }
        });
        editor.ui.addButton('Post', {
            label: THIS.i18n.postText(),
            command: 'post'
        });

    }
} );

I’ve also tried with setData("some text") and THIS.editor.setData("") (I have a reference to the editor saved in the View) but both had the same result. Any ideas about what is going wrong?

EDIT
I’ve also tried using CKEditor’s integration with jQuery with this call THIS.$el.find('textarea' + this.id).val(""); and it doesn’t flash anymore, but it still doesn’t clear out the editor.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:04:16+00:00Added an answer on June 14, 2026 at 2:04 pm

    The problem was twofold: First, setData calls a function, afterSetData, at the end of the function and that function calls getData. getData calls the function beforeGetData at the beginning of the function and that function calls setData. I think the goal was to get around the fact that there’s a lot of shallow referencing instead of deep referencing but even in the un-minified ckeditor.js it was unclear why this was done.

    And Second, that I was also calling disableEnablePost, in order to correctly enable/disable posting from the editor to the site, on many events (focus, key[down], etc). disableEnablePost called getData which caused timing issues with my call to setData in the post plugin.

    Problem:

    CKEDITOR.plugins.add( 'post', {
        init: function( editor ) {
            editor.addCommand('post', {
                exec: function(editor) {
                    THIS.model.postMessage(editor.getData());
                    THIS.options.data = "";
                    editor.setData("");
                }
            });
            editor.ui.addButton('Post', {
                label: THIS.i18n.postText(),
                command: 'post'
            });
            editor.on('key', function (event) {
                THIS.disableEnablePost(editor.getCommand( 'post' ), event);
            });
        }
    } );
    

    Here is my solution:

    CKEDITOR.plugins.add( 'post', {
        init: function( editor ) {
            editor.addCommand('post', {
                exec: function(editor) {
                    THIS.model.postMessage(editor.getData());
                }
            });
           ...
        }
    } );
    

    model.postMessage now triggers an event when it has completed which is caught in the view and then calls this function:

    clearRTE: function() {
        this.editor.setData("");
        this.options.data = "";
    }
    

    Finally, I changed disableEnablePost so that it doesn’t call getData every time, which was not a good practice. Now, it calls editor.getSnapshot() which is much more lightweight, there’s no data processing, and no calls to either getData or setData so it’s better for the frequent use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an instance of UIToolbar that contains a UITextField inside. I'd like to
I have an instance of Class A that I want to refer to in
I have a ckeditor plugin that depends on some custom parameters. These parameters may
I have an instance method that I'd like to invoke directly using the callback
I have an instance of CKEditor on a page. I am trying to give
With CKEDITOR, when I use JS to get the contents of the Text Editor,
I am using CkEditor for by replacing a text area. I want to open
I have two CKeditor fields that are a part of the form. I have
I have a few view helpers that add JavaScript files when they're needed (for
Reading through the CKEditor documentation , I see that they have an option to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.