【发布时间】:2012-02-11 04:20:27
【问题描述】:
我想在 TinyMCE 中指定元素(例如,表格)的每个实例旁边显示一个按钮(例如,span.mybutton)——然后,当单击该按钮时,抓取该特定元素的 html,处理它,然后在编辑器中更新它。
我可以处理处理,但我不知道如何显示按钮并传入获取特定元素的 html。例如,如果我这样做,它会将 span.mybutton 的 html 添加到 TinyMCE,就好像它是我不想要的常规内容一样:
jQuery('iframe#content').contents().find('table').append('<span class="mybutton">My button</span>');
这是我想要做的:
function processElement( element, values ) {
// do stuff to the table html (I don't need help with this part)
return element;
}
function appendButtonToTinyMCEElement ( button, element ) {
// put button next to all instances of the specified element in TinyMCE
// (in this case, put span.mybutton at the corner of all tables)
}
$('.myhelperbutton').click(function(){
var element = ??? // get content of the element whose button was clicked
var element = processElement( element );
// send element back to TinyMCE (not sure how)
});
所以,我的两个问题是: 如何在不影响保存在 TinyMCE 中的 html 的情况下在正确的位置显示按钮?而且,当单击按钮时,如何从 TinyMCE 获取/设置该元素?
【问题讨论】:
标签: javascript jquery tinymce