Skip to content

API Reference

Common Attribute Reference

The following are core attributes that you will reach for commonly.

AttributeDescription
data-requestmakes a request to a given AJAX handler
data-request-datasupplies postback data with the request
data-request-querysupplies query data with the request and modifies the URL
data-request-triggerthe event that triggers the request
data-request-pollautomatically triggers the request at a regular interval
data-request-updaterequest specified partial view updates

Additional Attribute Reference

All other attributes are specified below.

AttributeDescription
data-request-confirmdisplays a confirmation message before sending the request.
data-request-before-sendexecute JavaScript before the request is sent.
data-request-before-updateexecute JavaScript before the page contents are updated.
data-request-successexecute JavaScript on a successful request.
data-request-errorexecute JavaScript on a failed request.
data-request-completeexecute JavaScript on every completed request.
data-request-cancelexecute JavaScript if the user aborts the request or cancels it via a confirmation dialog.
data-request-redirectspecifies a URL to redirect the browser after the successful AJAX request.
data-request-messagedisplays a progress message with the specified text, shown while the request is running.
data-request-downloadwhen specified file downloads are accepted with a Content-Disposition response.
data-request-fileswhen specified the request will accept file uploads using the FormData interface.

Available Events

EventTargetDescription
ajax:before-sendwindowfired before sending a request.
ajax:before-updatetriggerfired after the request is complete, but before the page is updated.
ajax:updateelementfired after the element has updated.
ajax:update-completewindowfired after all elements have updated.
ajax:request-successwindowrequest has completed successfully.
ajax:request-errorwindowrequest encountered an errors.
ajax:error-messagewindowan error message wants to display.
ajax:confirm-messagewindowa confirm message wants to display.
ajax:setuptriggerbefore a request is formed.
ajax:promisetriggerbefore the request is sent.
ajax:donetriggerthe request was successful.
ajax:failtriggerthe request failed.
ajax:alwaystriggerthe request failed or was successful.

Available Response Methods

MethodDescription
update()adds DOM updates to the AJAX response
data()adds response data to the response
redirect()adds a browser redirect to the response
reload()adds a browser refresh command to the response
flash()adds flash messages to the response
error()adds an error message to the response
fatal()adds a fatal error message to the response
js()adds a JavaScript file or files to load with the output
css()adds a StyleSheet file or files to load with the output
img()adds an image file or files to load with the output
browserEvent()adds browser event dispatch with the response
browserEventAsync()adds asynchronous browser event dispatch with the response
invalidFields()adds invalid form fields to the response
partials()provides multiple requested partial responses to the browser
exception()processes an exception as an response

Available Override Methods

MethodDescription
registerCustomResponse()replaces the AjaxResponse class with a custom one
registerGlobalComponent()register a stateless component class available globally

JavaScript API Reference

MethodDescription
jax.ajax()issues an AJAX request
jax.request()issues an AJAX request with a form element
jax.flashMsg()displays a flash message
jax.progressBar()displays the progress bar
jax.attachLoader()flags an element as loading
jax.pageReady()waits for the page to be ready
jax.waitFor()waits for a an object to exist
jax.dispatch()triggers a global event
jax.trigger()triggers an event on an element
jax.on()triggers an event on an element
jax.off()triggers an event on an element
jax.values()extract the input values from a container element.

Turbo Router Functions

MethodDescription
jax.useTurbo()returns true if turbo routing is enabled
jax.visit()updates the page location

Hot Control Functions

MethodDescription
jax.registerControl()registers a new hot control
jax.importControl()returns a registered hot control class definition
jax.observeControl()attach a hot control and return the instance
jax.fetchControl()fetch an instance on a single element
jax.fetchControls()fetch instances on a multiple elements