jodit 에디터 질문

jodit 에디터 질문

QA

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 파일입니다.




<textarea id="ca_head_html" name="ca_head_html" class="jodit" maxlength="65536" style="width: 100%; height: 500px; display: none;"></textarea>

<script>
var ca_head_html_editor = new Jodit("#ca_head_html",{
            uploader: {
                url: "https://XXX.com/plugin/editor/jodit/upload.php",
                insertImageAsBase64URI: false,
                imagesExtensions: ["jpg", "png", "jpeg", "gif"],
                process: function (resp) {
                    for(var i=0;i<resp.data.images.length;i++){
                        ca_head_html_editor.setEditorValue(ca_head_html_editor.getEditorValue() +"<img src='" + resp.data.baseurl + "/" + resp.data.images[i] + "'>");
                    }
                }
            },
            height:300,
            allowResizeX: true,
            allowResizeY: true,
        });
</script>

자체적으로 해결하였습니다 :)

 

/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;
    }
답변을 작성하시기 전에 로그인 해주세요.
전체 59,279
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT