Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10382 closed Bug (invalid)

CKEDITOR.currentInstance returns null on focus

Reported by: Mandeep Owned by:
Priority: Normal Milestone:
Component: General Version: 4.0.2
Keywords: Cc:

Description

I am using the inline CKEditor. I have many text boxes on the page. When I click on the text box on which the inline CKEditor is used, I get the current instance using CKEDITOR.currentInstance. But when I visit the text box by pressing tab, I get the CKEDITOR.currentInstance as null. The toolbar is displayed in both cases('click' and 'tab focus').

Change History (3)

comment:1 Changed 11 years ago by Jakub Ś

Resolution: invalid
Status: newclosed

I can't confirm this. I have tried two approaches here to attach focus event to editor in massive inline creation sample. In both cases once events have been registered they worked on click and on tab.

CKEDITOR.on( 'instanceReady', function( event ) {
			event.editor.on('focus', function(evt){
				console.log(CKEDITOR.currentInstance);		
			});
		
		});
		window.setTimeout(function(){
			for (var propertyName in CKEDITOR.instances) {
				if ( CKEDITOR.instances.hasOwnProperty( propertyName ))
					CKEDITOR.instances[propertyName].on('focus', function(evt){
						console.log(CKEDITOR.currentInstance);		
					});
			}
			}, 2000);

@Mandeep Jain I'm closing this ticket as invalid but if I have missed anything and you don't agree please let me know.

comment:2 Changed 11 years ago by Mandeep

@j.swiderski I used the same approach, the only difference is that my timeout is 100ms.

Initially I was doing it without setTimeout which was not working. Then I set it to 0ms and 10ms which still gave me unpredictable results. Setting it to 100ms is working for now.

Can we achieve this without setTimeout?

comment:3 Changed 11 years ago by Jakub Ś

Yes it can be achieved. Please see first example.
On each instance ready you can attach focus event or whatever you want.

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