IEventEmitter
types.IEventEmitter
Hierarchy
-
↳
IEventEmitter
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
currents
currents: string[]
Defined in
mute
mute(event?): IEventEmitter
Doesn't start any handler
Parameters
| Name | Type |
|---|---|
event? |
string |
Returns
Defined in
isMuted
isMuted(event?): boolean
No handlers are triggered for the event
Parameters
| Name | Type |
|---|---|
event? |
string |
Returns
boolean
Defined in
unmute
unmute(event?): IEventEmitter
Returns event handling
Parameters
| Name | Type |
|---|---|
event? |
string |
Returns
Defined in
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
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
on(object, event, callback): this
Parameters
| Name | Type |
|---|---|
object |
Document |
event |
"selectionchange" |
callback |
CallbackFunction<any> |
Returns
this
Defined in
one
one(events, callback, options?): this
Parameters
| Name | Type |
|---|---|
events |
CanArray<string> |
callback |
CallbackFunction<any> |
options? |
IEventEmitterOnOptions |
Returns
this
Defined in
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
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
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
off(subjects, events?, callback?): IEventEmitter
Parameters
| Name | Type |
|---|---|
subjects |
CanArray<object | Window | HTMLElement> |
events? |
string | string[] |
callback? |
CallbackFunction<any> |
Returns
Defined in
stopPropagation
stopPropagation(subjectOrEvents, eventsList?): void
Parameters
| Name | Type |
|---|---|
subjectOrEvents |
string | object |
eventsList? |
string |
Returns
void
Defined in
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
fire(subject, eventsList, ...args): any
Parameters
| Name | Type |
|---|---|
subject |
object |
eventsList |
string | Event |
...args |
any[] |
Returns
any
Defined in
fire(subjectOrEvents, eventsList?, ...args): any
Parameters
| Name | Type |
|---|---|
subjectOrEvents |
string | object |
eventsList? |
any |
...args |
any[] |
Returns
any
Defined in
destruct
destruct(jodit?): any
Parameters
| Name | Type |
|---|---|
jodit? |
IViewBased<IViewOptions> |
Returns
any
Inherited from
Defined in
jodit/src/types/types.d.ts:32