Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding multiple events

How can I bind multiple events on tinymce such that those events e.g. click, keyup and change have the same handler function?

I am trying like this but the events are not firing.

tinymce.dom.Event.add(ed, 'click keyup change', function (ed, e) {
     // Handler here...                   
});

I also tried this where ed is my document

ed.bind('click keyup change', function (ed, e) {
     // Handler here...
});

but bind is not defined for tinymce. How can I get this working?

Thanks :)

like image 639
Bernice Avatar asked Aug 01 '26 14:08

Bernice


2 Answers

function myFunction(ed, e) {
    // do what you want
}

tinymce.dom.Event.add(ed, 'click', myFunction);
tinymce.dom.Event.add(ed, 'keyup', myFunction);
tinymce.dom.Event.add(ed, 'change', myFunction);
like image 118
Ricardo Alvaro Lohmann Avatar answered Aug 03 '26 04:08

Ricardo Alvaro Lohmann


Make one callback function and pass it to each of them

I do not believe that tinymce gives you the ability to add multiple events at once.

For example:

callbackFn = function (ed, e) {
     // Handler here...                   
};
tinymce.dom.Event.add(ed, 'click', callbackFn );
tinymce.dom.Event.add(ed, 'keyup', callbackFn );
...
like image 45
Naftali Avatar answered Aug 03 '26 02:08

Naftali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!