How to use the naja.registerExtension function in naja

To help you get started, we’ve selected a few naja examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / naja / naja-tests.ts View on Github external
}
    }
}

const genericListener = (event: StartEvent | AbortEvent): void => console.log(event.xhr);

const completeListener = (event: CompleteEvent): void => {
    if (event.error) {
        console.error(event.error);
    }
};

const successListener: NajaEventListener> = event =>
    console.log(event.response.message);

naja.registerExtension(TestExtension, 'optionalArg');

naja.historyHandler.uiCache = false;
naja.formsHandler.netteForms = {};
naja.formsHandler.initForms(document.body);
naja.formsHandler.processForm(new Event('submit'));
naja.uiHandler.allowedOrigins.push('http://localhost');

naja.snippetHandler.addEventListener('beforeUpdate', event => console.log(event.snippet, event.content));
naja.snippetHandler.addEventListener('afterUpdate', event => console.log(event.snippet, event.content));

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));