2013-08-18 1 views
1

AJAX를 사용하여로드 된 텍스트 영역에 주석을 설정하는 방법을 찾고 있습니다.동적으로로드 된 텍스트 영역을 tinyMCE로 변환합니다.

나는 TinyMCE에 4.0.2이 (축소 된)를 사용하여, 나는이 방법을 발견했다 :이 페이지를 통해

var ed = tinymce.get('content'); 
//ed.init(); 
ed.render(); 
//ed.focus(); 

을 : http://www.tinymce.com/wiki.php/api4:class.tinymce.Editor

코드 코멘트 나 혼자 테스트 또는 더 함께하지 다른 솔루션입니다 다른 결과

이 변경 사항은 거의 정확하지만 텍스트 영역은 잘되지만 액세스 할 수 없으므로 수정할 수 없습니다.

심지어이 방법을 통해 새로운 TinyMCE에를 만들려고 :

var ed = new tinymce.Editor('content'); 

을하지만이 작동하지 않습니다 (형식 오류 : r은 정의되지 않는다).

그리고 마지막으로, 난 이런 예전의 코드 테스트 :

tinymce.execCommand("mceAddControl", false, "content"); 

을하지만

그래서 나는, 순간에 붙어있어 당신이 내 실수를 수정하는 방법을 알 것 확인에 여전히 해요 ? JQuery를 사용하지만 plugins tinymce.jquery를 사용하지 않고 JS 프레임 워크를 자유롭게 변경할 수 있기를 원합니다. 그러나 분명히 경우, 나는 (http://fiddle.tinymce.com/rsdaab을 통해)이 코드를 시도했다 :

$('#content').tinymce(); 

중 하나가 작동하지 않습니다. 여기 는 JS 코드는 내가 사용된다

$.ajax({ 
    url:'/admin/post/new', 
    type:'get' 
}) 
    .done(function(data) { 
     $('#main').html(data); 
     var ed = tinymce.get('content'); 
     ed.render(); 
    }); 

은 잘 부탁드립니다

답변

0

함수 만들기 : 다음

function tinyMceLoader(tinyMceID) { 
    var ed = new tinymce.Editor(tinyMceID, 
      { 
       mode: "textareas", 
       theme: "advanced", 
       skin: "o2k7", 
       directionality: "rtl", 
       plugins: "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", 
       // Theme options 
       theme_advanced_buttons1: "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect,|,cut,copy,paste,pastetext,pasteword|,insertdate,inserttime,preview,|,forecolor", 
       theme_advanced_buttons2: "search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage,|,print", 
       theme_advanced_buttons3: "ltr,rtl,|,tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,backcolor", 
       theme_advanced_buttons4: "", 
       theme_advanced_toolbar_location: "top", 
       theme_advanced_toolbar_align: "right", 
       theme_advanced_statusbar_location: "bottom", 
       theme_advanced_resizing: true 
      }, 
    tinymce.EditorManager); 
    ed.render(); 
} 

:

$.ajax({ 
    url:'/admin/post/new', 
    type:'get' 
    processData: false, 
    contentType: false, 
    success: function (e) { 
        //some code .... 
        tinyMceLoader('content');   
      } 
    }); 
관련 문제