Skip to content

API Attribute

Overview

The API Attribute plugin provides a faster way to call API function based on the data-api and data-args attributes. This plugin allows users to click on elements that are tagged with data-api to trigger api function call.

Usage

To use the API Attribute plugin:

  1. Edit HTML: Click on Edit HTML in the screen editor.
  2. Add the data-api Attribute: Add the data-api attribute to any clickable element (such as buttons) in your HTML code.
  3. Set the data-api Value: Set the value of the data-api attribute to the API Function you want to call. e.g.
    <div data-api="Alert"></div>
    
    Read List of JavaScript API functions
  4. Add the data-args Attribute: Add the data-args attribute to element in your HTML code.
  5. Set the data-args Value: Set the value of the data-args attribute to set the arguments of that API Function you want to call. e.g.
    <div data-api="Alert" data-args='"Hello, World!"'></div>
    
  6. Clicking the Element: When the element is clicked, the plugin will call the API function mentioned in data-api with arguments provided in data-args attributes.

Important Note about Arguments Format

The data-args attribute value should be wrapped in single quote ', and multiple arguments are separated with comma , and strings are wrapped in double quotes "; e.g.

 <div data-api="ScreenTitle" data-args='1, "Leave a message for me!"'>
 <div data-api="Alert" data-args='"Hello, World!"'></div>

Example

Here’s an example of how to use the API Attribute plugin in your HTML:

Example Usage

 <div data-api="ScreenTitle" data-args='1, "Leave a message for me!"'>

Benefits

  • Minimal configuration: Just add the data-api and data-args to perform simple action without need for custom properties setup.

Notes

  • The plugin works with any clickable element such as buttons, links, or custom elements