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-api
Attribute: Add thedata-api
attribute to any clickable element (such as buttons) in your HTML code. - Set the
data-api
Value: Set the value of thedata-api
attribute to the API Function you want to call. e.g. Read List of JavaScript API functions - Add the
data-args
Attribute: Add thedata-args
attribute to element in your HTML code. - Set the
data-args
Value: Set the value of thedata-args
attribute 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-api
with arguments provided indata-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
Benefits
- Minimal configuration: Just add the
data-api
anddata-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