﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
13813	When calling CKEDITOR.replace with two extra Plugins twice, the editor does not load on the second time	Dmitry		"I am trying to add two extra plugins. Every time I open the editor, I call CKEDITOR.replace. It works fine first time I open the editor, however if I close it and reopen it again (i.e. call CKEDITOR.replace again), the editor never loads. Also, I noticed that if I leave a single plugin, the problem disappears.

I have took a look into the source code and I found a mistake in the CKEDITOR.scriptLoader.load method.

{{{
var scriptCount = scriptUrl.length;

// ...

for (var i = 0; i < scriptCount; i++) {
    loadScript( scriptUrl[ i ] );
}

// ...

var checkLoaded = function( url, success ) {
    ( success ? completed : failed ).push( url );
    if ( --scriptCount <= 0 ) {
	showBusy && CKEDITOR.document.getDocumentElement().removeStyle( 'cursor' );
	doCallback( success );
   }
};
}}}

As you can see, there is a loop, where loadScript is called for each scriptURL (a number of scriptURLs equals to scriptCount). However it turns out that loadScript decreases the scriptCount. So if scriptCount = 2, the second scriptURL does not have a chance to be processed, because the loop is ended after the first iteration!

I have resolved this problem by replacing scriptCount to scriptUrl.length in the loop:


{{{
for (var i = 0; i < scriptUrl.length; i++) {
    loadScript( scriptUrl[ i ] );
}
}}}

You may want to apply this fix."	Bug	closed	Normal		General		expired		
