2014-07-25 101 views
0

我曾经有一个类名为“.dyskografia”的textarea,我正在访问该类以便将一些内容粘贴到该类中。TinyMCE编辑器 - 如何通过jQuery访问自定义属性

它曾经是这样的:

$(this.el).find('.dyskografia').html("blah blah blah"); 

当我纳入TinyMCE的编辑器,它搞砸了我的标签,现在我想这是我应该reffering到 - 数据-ID =“Dyskografia” :

<body id="tinymce" class="mce-content-body " data-id="Dyskografia" contenteditable="true" spellcheck="false"><p>...</p></body> 

我怎样才能改变我以前的代码中粘贴“等等等等等等”与数据ID =“Dyskografia”的标签?

+0

你要插入标签或到编辑器? – martinezjc

回答

1

您可以设置TinyMCE的编辑与此内容:

// Sets the HTML contents of the activeEditor editor 
tinyMCE.activeEditor.setContent('<span>some</span> html'); 

// Sets the raw contents of the activeEditor editor 
tinyMCE.activeEditor.setContent('<span>some</span> html', {format : 'raw'}); 

// Sets the content of a specific editor (my_editor in this example) 
tinyMCE.get('my_editor').setContent(data); 

// Sets the bbcode contents of the activeEditor editor if the bbcode plugin was added 
tinyMCE.activeEditor.setContent('[b]some[/b] html', {format : 'bbcode'}); 

如果你在的更多信息感兴趣,你可以阅读documentation