Toggle
Last updated
Was this helpful?
Last updated
Was this helpful?
This block type renders a toggle link that sends an AJAX request on every subsequent click, changing its icon and label depending on the current state.
view - the link view, set to icon
if labels are not required;
url - the URL for sending AJAX requests on click;
states - an array of the link state parameters;
attributes - the link HTML attributes;
active - true
if the toggle link is currently active.
The code below renders a toggle link that displays the "Follow" text with the user-plus
icon when inactive and the "Unfollow" text with the user-minus
icon when active. It sends an AJAX request to the https://example.com
URL, changing the link icon and label on every subsequent click.