是否有人在tinyMCE中使用了tinymce.dom.Selection类?我试图将函数应用于dom.Selection.onBeforeSetContent或onSetContent,但失败了。文档显示了以下语法:
event_callback(<tinymce.dom.Selection> ed, <Object> o)它的实现没有一个很好的例子。我很着急,快要放弃了。
到目前为止,我已经尝试过的是:
$('#tinyMce').tinymce({
...
setup: function(ed) {
ed.dom.Selection.onSetContent.add(function(se,o){...});
}
});这将失败,并显示"ed.dom is undefined“。我也试过了:
$('#tinyMce').tinymce({
...
init_instance_callback : "CustomInitInstance"
});
function CustomInitInstance(inst){
//inst.dom.Selection.on... fails with "inst.dom is undefined"
tinymce.dom.Selection.onBeforeSetContent.add(function(se,o){...}); // fails with "tinymce.dom.Selection.onBeforeSetContent is undefined"
}发布于 2010-08-21 11:02:47
ed.selection.onBeforeSetContent.add(function(se, o) {
alert(o.content);
});如果将内容粘贴到第一个示例中,上面的代码应该会触发一个包含要插入的内容的警告
发布于 2010-12-03 18:34:30
$('#tinyMce').tinymce({
...
setup: function(ed) {
ed.onInit.add(function(ed, o) {
ed.selection.onBeforeSetContent.add(function(se,o){
alert(o.content);
});
});
}
});它在调用ed.selection.setContent('my text')之前起作用
alert (o.content); // display 'my text'https://stackoverflow.com/questions/1341035
复制相似问题