tags:

views:

359

answers:

1

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(fucntion(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"
}
A: 

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

wtb