본문 바로가기
study/javascript

Ckeditor4 placeholder

by 땅콩잉 2021. 11. 8.
728x90

한 페이지에 여러개의 에디터를 뒀을 때 각자 다른 placeholder를 줘야하는 상황에 사용할 수 있다.

 

해당 사이트 들어가서 플러그인 다운받고 plugins 폴더에 넣는다!

https://ckeditor.com/docs/ckeditor4/latest/features/editorplaceholder.html

 

Editor Placeholder - CKEditor 4 Documentation

Learn how to install, integrate and configure CKEditor 4. More complex aspects, like creating plugins, widgets and skins are explained here, too. API reference and examples included.

ckeditor.com

 

 

 <textarea id="question-answer<?php echo $i; ?>" placeholder="<?php echo $data[$i]; ?> "class="question-answer" ~~~~>

textarea에 아이디를 넣어주고 각자 다른 플레이스 홀더 내용을 넣고...

아이디를 가져와서 replace하도록!(?)ㅋㅋㅋ

 $('.question-answer').each(function(i,item){
            console.log(item);
           var sPlaceholderText = $(item).attr('placeholder');
            var editor2 = CKEDITOR.replace('question-answer'+i,{
                height: 300,
                editorplaceholder : sPlaceholderText,
            });
        })

 

- 잘못된 소스

이렇게 해도 계속 안되서 안되는건가 싶었는데 ㅠ.. 아래처럼 사용 하던 분들은 위에처럼 바꾸셔요.

 var editor2 = CKEDITOR.replaceAll('question-answer',{ //class명
            // extraPlugins : 'editorplaceholder',
            extraPlugins : 'editorplaceholder',
            editorplaceholder : 'testte123st',
        });

댓글