IEventEmitter

types.IEventEmitter

Hierarchy

Implemented by

current

current: string

Get current event name

Example

parent.e.on('openDialog closeDialog', function () {
    if (parent.e.current === 'closeDialog') {
        alert('Dialog was closed');
    } else {
        alert('Dialog was opened');
    }
});
Defined in

src/types/events.d.ts#35


currents

currents: string[]

Defined in

src/types/events.d.ts#36

mute

mute(event?): IEventEmitter

Doesn't start any handler

Parameters

Name Type
event? string

Returns

IEventEmitter

Defined in

src/types/events.d.ts#41


isMuted

isMuted(event?): boolean

No handlers are triggered for the event

Parameters

Name Type
event? string

Returns

boolean

Defined in

src/types/events.d.ts#46


unmute

unmute(event?): IEventEmitter

Returns event handling

Parameters

Name Type
event? string

Returns

IEventEmitter

Defined in

src/types/events.d.ts#51


on

on(events, callback, options?): this

Sets the handler for the specified event (Event List) for a given element .

Parameters

Name Type
events CanArray<string>
callback CallbackFunction<any>
options? IEventEmitterOnOptions

Returns

this

Example

// set global handler
parent.on('beforeCommand', function (command) {
    alert('command');
});

Example

// set global handler
parent.on(document.body, 'click', function (e) {
    alert(this.href);
}, 'a');
Defined in

src/types/events.d.ts#77

on(subject, events, callback, options?): this

Parameters

Name Type
subject CanArray<object | Window | HTMLElement>
events CanArray<string>
callback CallbackFunction<any>
options? IEventEmitterOnOptions

Returns

this

Defined in

src/types/events.d.ts#83

on(object, event, callback): this

Parameters

Name Type
object Document
event "selectionchange"
callback CallbackFunction<any>

Returns

this

Defined in

src/types/events.d.ts#180


one

one(events, callback, options?): this

Parameters

Name Type
events CanArray<string>
callback CallbackFunction<any>
options? IEventEmitterOnOptions

Returns

this

Defined in

src/types/events.d.ts#90

one(subject, events, callback, options?): this

Parameters

Name Type
subject CanArray<object | Window | HTMLElement>
events CanArray<string>
callback CallbackFunction<any>
options? IEventEmitterOnOptions

Returns

this

Defined in

src/types/events.d.ts#96


off

off(events, callback?): IEventEmitter

Disable all handlers specified event ( Event List ) for a given element. Either a specific event handler.

Parameters

Name Type
events CanArray<string>
callback? CallbackFunction<any>

Returns

IEventEmitter

Example

var a = {name: "Anton"};
parent.e.on(a, 'open', function () {
    alert(this.name);
});

parent.e.fire(a, 'open');
parent.e.off(a, 'open');
var b = {name: "Ivan"}, hndlr = function () {
 alert(this.name);
};
parent.e.on(b, 'open close', hndlr);
parent.e.fire(a, 'open');
parent.e.off(a, 'open', hndlr);
parent.e.fire(a, 'close');
parent.e.on('someGlobalEvents', function () {
  console.log(this); // parent
});
parent.e.fire('someGlobalEvents');
parent.e.off('someGlobalEvents');
Defined in

src/types/events.d.ts#129

off(subjects, events?, callback?): IEventEmitter

Parameters

Name Type
subjects CanArray<object | Window | HTMLElement>
events? CanArray<string>
callback? CallbackFunction<any>

Returns

IEventEmitter

Defined in

src/types/events.d.ts#131


stopPropagation

stopPropagation(subjectOrEvents, eventsList?): void

Parameters

Name Type
subjectOrEvents string | object
eventsList? string

Returns

void

Defined in

src/types/events.d.ts#137


fire

fire(eventsList, ...args?): any

Sets the handler for the specified event (Event List) for a given element .

Parameters

Name Type Description
eventsList string List of events , separated by a space or comma
...args? any[] Options for the event handler

Returns

any

false if one of the handlers return false

Example

var dialog = new Jodit.modules.Dialog();
parent.e.on('afterClose', function () {
    dialog.destruct(); // will be removed from DOM
});
dialog.open('Hello world!!!');

or you can trigger native browser listener

 var events = new Jodit.modules.EventEmitter();
 events.on(document.body, 'click',function (event) {
     alert('click on ' + event.target.id );
 });
 events.fire(document.body.querySelector('div'), 'click');
Defined in

src/types/events.d.ts#166

fire(subject, eventsList, ...args): any

Parameters

Name Type
subject object
eventsList string | Event
...args any[]

Returns

any

Defined in

src/types/events.d.ts#167

fire(subjectOrEvents, eventsList?, ...args): any

Parameters

Name Type
subjectOrEvents string | object
eventsList? any
...args any[]

Returns

any

Defined in

src/types/events.d.ts#168


destruct

destruct(jodit?): any

Parameters

Name Type
jodit? IViewBased<IViewOptions>

Returns

any

Inherited from

IDestructible.destruct

Defined in

jodit/src/types/types.d.ts:32