问题
Pre-note: This issue occurs whether or not I already have a textarea on the page.
I have a button that triggers an ajax request first...writing something to a database and returning the key. I use that key in my ID for the textarea that is then dynamically added to page. Keep in mind that tinyMCE is already initialized.
tinymce.init({
selector: ".editor",
setup: function(ed) {
ed.on('change', function(e) {
tinymce.triggerSave();
$('form').trigger('checkform.areYouSure');
});
ed.on('init', function(e) {
autoresize_max_height: 500
});
},
plugins: [
"advlist autolink link responsivefilemanager lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality template paste textcolor colorpicker responsivefilemanager autoresize"
],
toolbar: "undo redo | styleselect | bold italic | forecolor backcolor | alignleft aligncenter alignright | bullist numlist | outdent indent | table | link responsivefilemanager",
image_advtab: true ,
external_filemanager_path:"/filemanager/",
filemanager_title:"Filemanager" ,
external_plugins: { "filemanager" : "/filemanager/plugin.min.js"},
});
After the textarea is dynamically created, I add some default 'Lorem Ipsum' text and call mceAddEditor
tinymce.execCommand('mceAddEditor', false, "custom-html_" + data.c2akey);
data.c2akey is the key returned from the ajax call.
The tinymce instance is created successfully.
Here's the problem:
1) I can not type in this newly created instance
2) The instance is super tall. Unless I set a static height on the parent container the textarea is, the editor is really tall. See tinyMCE 4 instance after mceAddEditor really tall
So I need help figuring out why I can't type in this instance.
来源:https://stackoverflow.com/questions/26737588/cant-type-in-tinymce-4-instance-after-mceaddeditor