javascript
  • tinymce
  • 2011-09-28 41 views 0 likes 
    0

    我有一個這樣的javascript代碼。使用innerHTML從javascript呈現微小的mce

    after_add_content_for_popup = "<div><div><textarea name='notes' rows='10' cols='17' class='rich' id='parent_note_content'>"+notecontent+"</textarea></div><div style='float:right;margin-left:20px;padding-left:10px;'><input id='submitbutton' class='flat_btn' style='margin-top:5px;' type='button' title='Edit category note' value='Save' name='submitbutton' onclick=\"update_category_note('P','"+categoryid+"','"+noteidnew+"');\"></div></div>"; 
    
            document.getElementById('parent_insert_div').innerHTML=''; 
            document.getElementById('parent_insert_div').innerHTML = after_add_content_for_popup; 
    

    但它只顯示textarea而不是tinymce編輯器。

    +0

    你如何解決它? –

    回答

    1

    您似乎並未首先添加TinyMCE。請看示例代碼頁:

    http://fiddle.tinymce.com/

    注意使用不同的選項添加TinyMCE的代碼:

    tinyMCE.init 
    ({ 
         // General options 
         mode : "textareas", 
         theme : "advanced", 
         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,imagemanager,filemanager", 
    
         // Theme options 
         theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", 
         theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", 
         theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", 
         theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage", 
         theme_advanced_toolbar_location : "top", 
         theme_advanced_toolbar_align : "left", 
         theme_advanced_statusbar_location : "bottom", 
         theme_advanced_resizing : true, 
         width: "100%", 
         height: "400" 
    }); 
    

    因此,包括TinyMCE的JS文件後,你必須還使用上面的代碼或類似的東西來初始化TinyMCE。

    相關問題