Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
document.addEventListener('DOMContentLoaded', () => {
naja.initialize();
naja.initialize({ history: false, selector: '[data-ajax]', customOption: 1 });
naja.fireEvent('customEvent', { extra: 1 });
naja.fireEvent('anotherEvent');
naja.addEventListener('testEvent', handler);
naja.addEventListener('someEvent', event => console.log(event.target));
naja.removeEventListener('testEvent', handler);
naja.removeEventListener('someEvent', event => {});
naja.addEventListener('otherEvent', event => console.log(event.otherProperty === 1));
});
naja.uiHandler.bindUI(document.createElement('div'));
naja.uiHandler.clickElement(document.createElement('button'));
naja.uiHandler.handleUI(new Event('change'));
naja.uiHandler.submitForm(document.createElement('form'));
naja.addEventListener('init', event => console.log(event.defaultOptions));
naja.addEventListener('interaction', event => console.log(event.element, event.originalEvent, event.options));
naja.addEventListener('before', event => console.log(event.data, event.method, event.url, event.xhr));
naja.addEventListener('start', genericListener);
naja.addEventListener('abort', genericListener);
naja.addEventListener('success', successListener);
naja.addEventListener('error', event => console.error(event.error));
naja.addEventListener('complete', completeListener);
naja.removeEventListener('start', genericListener);
naja.snippetHandler.removeEventListener('beforeUpdate', null);
type TestEvent = CustomEvent<{ customProperty: string }>;
interface OtherEvent extends Event {
otherProperty: number;
type: 'otherEvent';
}
const handler = (event: TestEvent): void => console.log(typeof event.detail.customProperty === 'string');
document.addEventListener('DOMContentLoaded', () => {
naja.initialize();
naja.initialize({ history: false, selector: '[data-ajax]', customOption: 1 });
naja.fireEvent('customEvent', { extra: 1 });
naja.fireEvent('anotherEvent');
naja.addEventListener('testEvent', handler);
document.addEventListener('DOMContentLoaded', () => {
naja.initialize();
naja.initialize({ history: false, selector: '[data-ajax]', customOption: 1 });
naja.fireEvent('customEvent', { extra: 1 });
naja.fireEvent('anotherEvent');
naja.addEventListener('testEvent', handler);
naja.addEventListener('someEvent', event => console.log(event.target));
naja.removeEventListener('testEvent', handler);
naja.removeEventListener('someEvent', event => {});
naja.addEventListener('otherEvent', event => console.log(event.otherProperty === 1));
});