Skip to content

Naja ​

Initializes and registers NajaCoreExtension from naja-extensions

Docs & Examples ​

Source ​

Tips ​

Outside the normal naja functions, with the NajaCoreExtension there are a few extended functionalities.

Button ​

You can make request via [data-naja] attribute also on button elements.

html
<button 
    data-naja 
    data-naja-url="/requested-url" 
    data-naja-method="POST" 
    data-naja-data='{ "someParam": true }'
>
    Make request
</button>

Events ​

Do something upon interaction.

html
<a data-naja href="/requested-url" data-action="naja:interaction->my-controller#doSomething"></a>

Do something when after snippet update.

html
<div id="snippet--redraw" data-action="naja:afterUpdate->my-controller#doSomething"></div>

Do something after form success.

html
<form data-naja data-action="naja:form-success->my-controller#doSomething"></form>

Do you need Naja? ​

Does your website really need Naja? If there are no ajax snippets, then consider removing it. And if there are only one or two ajax requests, you can do it manually via Fetch API.

Released under the MIT License.