jodit 에디터 질문
본문
관리자페이지 설정페이지에서 에디터를 여러개 호출하는 경우에,
다른 에디터는 동시에 여러개 잘 나오는데,
jodit에디터 (https://sir.kr/g5_plugin/7977) 는 제일 위쪽 한개만 나오고, 나머지는 에디터가 안뜨네요.
혹시 해결하신 분 계실까요?
답변 2
<div id="editor"></div> <script>var editor = new Jodit('#editor');</script>
id를 다 다르게 해 보세요.
자체적으로 해결하였습니다 :)
/plugin/editor/jodit/editor.lib.php 파일에서 스크립트 부분을 아래와 같이 수정해주어야합니다.
if ($is_dhtml_editor && $js) { 와 } 사이의 스크립트를 아래와 같이 바꿔줍니다.
수정된 부분
1) 스크립트 상단 추가
<script>
(function($){
$(document).ready(function() {
$(".jodit").each(function (){
2) var '.$id.'_editor = new Jodit("#'.$id.'",{ => var '.$id.'_editor = new Jodit(this,{ 변경
3) 스크립트 하단 추가
});
});
})(jQuery);
</script>
수정 전체 코드
if ($is_dhtml_editor && $js) {
$html .= "\n".'<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jodit/3.4.25/jodit.min.css">';
$html .= "\n".'<script src="//cdnjs.cloudflare.com/ajax/libs/jodit/3.4.25/jodit.min.js"></script>';
$html .= "\n".'
<script>
(function($){ //추가
$(document).ready(function() { //추가
$(".jodit").each(function (){ //추가
var '.$id.'_editor = new Jodit(this,{ //수정
uploader: {
url: "'.$editor_url.'/upload.php?bo_table='.$bo_table.'",
insertImageAsBase64URI: false,
imagesExtensions: ["jpg", "png", "jpeg", "gif"],
process: function (resp) {
for(var i=0;i<resp.data.images.length;i++){
'.$id.'_editor.setEditorValue('.$id.'_editor.getEditorValue() +"<img src=\'" + resp.data.baseurl + "/" + resp.data.images[i] + "\'>");
}
}
},
height:300,
allowResizeX: true,
allowResizeY: true,
});
}); //추가
}); //추가
})(jQuery); //추가
</script>';
$js = false;
}
답변을 작성하시기 전에 로그인 해주세요.