Reputation: 4820
Does someone used tinymce.dom.Selection class in tinyMCE? I'm unsuccessfully trying to apply a function to dom.Selection.onBeforeSetContent or onSetContent. The documentation shows the following syntax:
event_callback(<tinymce.dom.Selection> ed, <Object> o)
There's no neat example of its implementation. I'm in a hurry and tend to give up.
What i have already tried so far is:
$('#tinyMce').tinymce({
...
setup: function(ed) {
ed.dom.Selection.onSetContent.add(function(se,o){...});
}
});
which fails with "ed.dom is undefined". I also tried:
$('#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"
}
Upvotes: 1
Views: 3498
Reputation: 331
$('#tinyMce').tinymce({
...
setup: function(ed) {
ed.onInit.add(function(ed, o) {
ed.selection.onBeforeSetContent.add(function(se,o){
alert(o.content);
});
});
}
});
it works before calling ed.selection.setContent('my text')
alert (o.content); // display 'my text'
Upvotes: 4
Reputation: 36
ed.selection.onBeforeSetContent.add(function(se, o) {
alert(o.content);
});
The above should fire an alert containing the content to be inserted if you paste it into your first example
Upvotes: 2