开发者

render tiny mce from javascript using innerHTML

I have a javascript code like this.

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开发者_JAVA百科 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;

but it shows only the textarea not the tinymce editor.


You don't appear to be adding TinyMCE in the first place. Please look at the sample code on this page:

http://fiddle.tinymce.com/

Note the code used to add TinyMCE with various options:

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"
});

So, after including the TinyMCE JS files, you have to also initialize TinyMCE using the code above or something like it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜