I've added a toggle button to TinyMCE (using the jQuery plugin version) that looks like:
$('a.mce_show').click(function(){
/开发者_高级运维/ toggle all textareas
$('.wysiwyg').tinymce().show();
});
$('a.mce_hide').click(function(){
// toggle all textareas
$('.wysiwyg').tinymce().hide();
});
The problem is if you hide the editor, make a change and click 'submit' it'll discard the change. If you hide the editor, make a change, show the editor then click submit it'll be fine.
How do I get it to submit properly without having to re-show the editor?
The way they have the jQuery show/hide example on the tinymce site doesn't actually work. Instead of just hiding the editor, you actually need to unload and then reload it. So you should do something like the following:
$(function() {
var id = 'tinytextareaID'; // ID of your textarea (no # symbol)
$("a.toggle").toggle(function(){
tinyMCE.execCommand('mceRemoveControl', false, id);
}, function () {
tinyMCE.execCommand('mceAddControl', false, id);
});
});
精彩评论