Opened 12 years ago

Last modified 12 years ago

#8574 confirmed New Feature

Change contents of richcombo after init

Reported by: Amund Owned by:
Priority: Normal Milestone:
Component: General Version: 3.6.2
Keywords: HasPatch Cc:


I think richcombo plugin needs to be extended to support changing its contents after init has been run. This will enable developers to clientside refresh the list without loading the entire page where the editor is.

I have successfully done this with a bit of a hack in my own plugin that uses richcombo. In my code, I have a plugin that adds other plugins in the richcombo - e.g. insert link, insert image etc. This list may change due to userinput and it happens clientside.

How I solved it: (see

Some code: in the init function in ui.addRichCombo:

init: function () {
                var rebuildList =, this); // bind the buildList function with this scope
                rebuildList(); // call once to do first build of list
                $(editor).bind('rebuildList', rebuildList); // bind with jquery so we can call it later

then outside scope, define the buildList function:

var buildListHasRunOnce = 0;
        var buildList = function () {
            if (buildListHasRunOnce) {
                // Remove the old unordered list from the dom.
                // This is just to cleanup the old list within the iframe
                // Note that this removes all uls... if there are more than one editor on page, we have to be more specific on what to remove. In my production ready code, I target one of the lis, and find its ul parent and remove that instead of shotgunning all uls like in this example
                // reset list
                this._.items = {};
                this._.list._.items = {};
            for (var i in yourListOfItems) {
                var item = yourListOfItems[i];
                // do your add calls
                this.add(, 'something here as html', item.text);
            if (buildListHasRunOnce) {
                // Force CKEditor to commit the html it generates through this.add
                this._.committed = 0; // We have to set to false in order to trigger a complete commit()
            buildListHasRunOnce = 1;

I´m thinking that it should be at least possible to

  1. Get a handle on the richCombo object when you add it with editor.ui.addRichCombo
  2. Be possible to call clearRichCombo


  1. Add function remove
  2. Make it possible to call add after init. Currently you can, but it crashes the richCombos mark/unmarkall functions

Kind regards, Amund

Change History (3)

comment:1 Changed 12 years ago by Amund

By the way, you may also have to reset the pendingHtml array, I dont quite remember, but that´s details anyway.

comment:2 Changed 12 years ago by Anna Tomanek

Keywords: HasPatch added; richcombo removed
Status: newconfirmed

comment:3 Changed 12 years ago by Amund

My code is not a patch, its just sample code to show how I was able to reinit the richcombo after init and supplied to give ckeditor developers some idea on how I had to hack my way around it. Maybe also give them ideas on what needs to be done.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy