Skip to main content AWT Premium

AWT Premium

Custom click actions

Wire a Button, or a Modal’s main button, to your own JavaScript when a link isn’t enough. Your function, your logic, the block’s accessible markup.

How it works

  1. Write a JavaScript function in AWT Settings → Custom code, or in a file your theme or a plugin loads.
  2. Type its name in the Button’s On click settings, or in the Modal’s When the primary button is clicked.
  3. When someone clicks, your function runs and gets the click event.
The block editor with a Chat with a librarian button selected. The sidebar's On click panel has the function name openChat, and help text that explains what the function can do.
A button that runs openChat when it is clicked.

Your function decides

Return false to stop what the click would do: a link isn’t followed, a form isn’t sent, a modal stays open. Return anything else, and the block does what it always does.

If the function is missing or fails, the block still works as if it had none, and the browser’s console says why.

Only for people trusted with scripts

Only people who may add any HTML to your site, usually administrators, can set or change a function name. Others see it but can’t change it, and can still edit a page that has one.

The script loads only on pages that use a click action, and it works under a strict Content Security Policy.

The markup stays accessible

The Button stays a real button or link, with its name, focus and keyboard support. A Modal’s main button still closes the modal and puts focus back on the button that opened it.

Get AWT Premium

Click actions come with AWT Premium. The Carbon Edition is $299 a year for one live site, with every update and customer support.