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:
- Edit HTML: Click on Edit HTML in the screen editor.
- Add the
data-apiAttribute: Add thedata-apiattribute to any clickable element (such as buttons) in your HTML code. - Set the
data-apiValue: Set the value of thedata-apiattribute to the API Function you want to call. e.g. Read List of JavaScript API functions - Add the
data-argsAttribute: Add thedata-argsattribute to element in your HTML code. - Set the
data-argsValue: Set the value of thedata-argsattribute to set the arguments of that API Function you want to call. e.g. - Clicking the Element: When the element is clicked, the plugin will call the API function mentioned in
data-apiwith arguments provided indata-argsattributes.
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
Benefits
- Minimal configuration: Just add the
data-apianddata-argsto perform simple action without need for custom properties setup.
Notes
- The plugin works with any clickable element such as buttons, links, or custom elements