자율 학습/학습

CKEditor 에 keydown 이벤트 주는 방법

2022. 9. 18. 00:55

다른 요소들은 이렇게 줬었다.

//경고 메시지 사라지기
$("#material").on("keydown", "input", function(){
	$("#mNotice").hide();
});

 

근데 ck에디터는 어느 요소에 이벤트를 주든 안 먹히더라..

구글링해보니 ck에디터의 instanceReady 이벤트로 document에 접근해서 keydown 때 원하는 작업을 실행시키도록 해야 했다.

그래서 아래와 같이 하니 동작 잘 함!

//경고 메시지 사라지기
CKEDITOR.instances['con'].on("instanceReady", function(){
	this.document.on("keydown", function() {
		$("#cNotice").hide();
	});
});

 

출처: https://webisfree.com/2017-03-30/ckeditor-로딩된-상태를-알아내는-방법은

http://www.underroom.com/index.php?mid=javascript&listStyle=webzine&sort_index=regdate&order_type=asc&document_srl=5624