Functions
bindEvent(eventName: string, callback: Function, element: string): Function
Binds the given callback with context to 'eventName' on the element / document and returns the reference.
import Component from '@ember/component';
import EventHandler from '@freshworks/modal/utils/event-handler';
export default Component.extend({
state: null,
action: {
setFocusListener() {
let _focusListener = EventHandler.bindEvent({
context: this,
eventName: 'focusin',
callback: this.loopFocus
});
set(this, '_focusListener', _focusListener);
}
}
});Import Path
import
{ bindEvent }
from
'@freshworks/modal/utils/event-handler';
Params
| eventName | string | Name of the event to bind the callback to |
| callback | Function | Callback function for the eventhandler |
| element | string | element selector. Defaults to document |
unbindEvent(eventName: string, callback: Function, element: string): any
Unbinds the given callback from 'eventName' on the element / document.
import Component from '@ember/component';
import EventHandler from '@freshworks/modal/utils/event-handler';
export default Component.extend({
state: null,
action: {
setFocusListener() {
let _focusListener = EventHandler.unbindEvent({
eventName: 'focusin',
callback: this.loopFocus
});
set(this, '_focusListener', _focusListener);
}
}
});Import Path
import
{ unbindEvent }
from
'@freshworks/modal/utils/event-handler';
Params
| eventName | string | Name of the event to bind the callback to |
| callback | Function | Callback function for the eventhandler |
| element | string | element selector. Defaults to document |
Previous
safe-set