I am using tinymce editor
to a textarea with exact id. It is working fine on pageload.
But when I am clicking asp button 'Save' whick post backs to save the data in DB the active editor becomes null and does not retains its value.
How to overcome this problem?
My tinyMce init code in pageload is
tinyMCE.init({
mode: "exact",
elements : "divLabTemplateTree",
encoding: "xml",
convert_urls: false,
theme: "advanced",
width:"300",
height:"400",
skin : "o2k7",
plugins: "spellchecker,pagebreak,style,layer,table,advhr,advimage,advlink,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,paste,directionality,fullscreen,visualchars,nonbreaking,xhtmlxtras",
extended_valid_elements: "iframe[src|width|height|name|align]",
theme_advanced_buttons1: "spellchecker,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect,|,print,fullscreen",
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,media,advhr,|",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_path_location: "bottom",
theme_advanced_resizing: true,
theme_advanced_resize_horizontal: false,
dom_loaded : 1,
theme_advanced_styles: "Link to Image: lightbox;Image Right Border: rightbordered;Image Left Border: leftbordered;Darker Text: darker",
setup: function (ed) {
ed.onSaveContent.add(function (i, o) {
o.content = o.content.replace(/'/g, "&apos");
});
ed.onInit.add(function(ed) {
tinyMCE.execCommand("mceAddControl", true, "divLabTemplateTree");
});
}
});
I am setting its value
if(tinyMCE.activeEditor != null)
{
tinyMCE.activeEditor.setContent("bbbbbbbbbbbbbbb");
}
When a page gets initialized tinyMCE.activeEditor is null till the moment when a user explicitly clicks into the editor.
It is recommended to use tinymce.get('your_editor_id')
here. Your editor is equals your textarea id for which the editor gets initialized. If this textarea (or other html source elmenent) got no id then content
is used as default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With