Opened 10 years ago
Closed 9 years ago
#13813 closed Bug (expired)
When calling CKEDITOR.replace with two extra Plugins twice, the editor does not load on the second time
| Reported by: | Dmitry | Owned by: | |
|---|---|---|---|
| Priority: | Normal | Milestone: | |
| Component: | General | Version: | |
| Keywords: | Cc: |
Description
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.
Change History (2)
comment:1 Changed 10 years ago by
| Keywords: | scriptLoader removed |
|---|---|
| Status: | new → pending |
| Version: | 4.5.4 |
comment:2 Changed 9 years ago by
| Resolution: | → expired |
|---|---|
| Status: | pending → closed |

Could you provide the simplified code snippet you have used to reproduce this issue?
Besides reproducing I just wanted to exclude obvious and make sure that you are destroying the editor before creating new one.