4
我在初始化後將tinymce動態添加到textarea中遇到了一些問題。如何將tinymce 4.x動態添加到textarea?
tinymce.init({
selector: "textarea",
theme: "modern",
height: 100,
plugins: [
"advlist autolink image lists charmap print preview hr anchor pagebreak spellchecker",
"link searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality emoticons template paste textcolor"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l ink image | print preview media fullpage | forecolor backcolor emoticons",
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
]
});
而我的按鈕添加新的textarea:
$('#add_new_text').click(function(){
var n = 1;
$('<textarea class="cla" name="text'+n+'"></textarea>').appendTo('#wrap_f');
n++;
})
我試圖做到這一點tinyMCE.execCommand('mceAddControl', false, '');
但沒有奏效。
高興的是,它的工作! – ilter
太棒了!這工作很好!非常感謝和抱歉,這個愚蠢的問題;) –
沒有問題是愚蠢的。他們是問題,因爲你還不知道他們。歡迎來到社區;) – ilter