Spanish Total.js
English
Documentation For AI agents
Contents

ui-plugin

The attributes and the config keys of the ui-plugin element.

.md GitHub
On this page

The <ui-plugin> element creates an instance of a plugin declared with PLUGIN() and gives the elements inside it a common path. The Plugins guide explains how to work with it, and the instance is described on the Plugin page.

API

property

path="path"

The path of the plugin model, and the name of the declaration to use.

The attribute accepts these forms:

ValueModel pathDeclaration
ordersordersorders
target nametargetname
? namea generated path under jComponent.data.name
*commonPLUGIN('*', ...)
no attributethe name of the next declaration waiting for an elementthat declaration

When no declaration exists for the path, the element still works as a plugin without its own code.

One declaration, two models
<ui-plugin path="left counter"></ui-plugin>
<ui-plugin path="right counter"></ui-plugin>

<script>
PLUGIN('counter', function(exports) {
    exports.make = function() {
        console.log(exports.name);
    };
});
// logs: left
// logs: right
</script>
A generated model path
<ui-plugin path="? counter"></ui-plugin>

<script>
PLUGIN('counter', function(exports) {
    exports.make = function() {
        console.log(exports.name.substring(0, 16));
    };
});
// logs: jComponent.data.
</script>
property

config="key:value;key:value"

The configuration of the plugin instance.

The format is the same as in ui-component. Besides the keys below, the plugin reads any key of its own from exports.config.

Read the configuration
<ui-plugin path="report" config="limit:20"></ui-plugin>

<script>
PLUGIN('report', 'limit:5;sort:name', function(exports, config) {
    console.log(config.limit, config.sort);
});
// logs: 20 name
</script>
config

init:path

Calls a function when the plugin is created, just ahead of make.

The function receives the jQuery element of the plugin. A ? in the value is replaced with the path of the plugin, so ?/ready calls the ready method of the same plugin.

Call a method of the plugin
<ui-plugin path="report" config="init:?/ready"></ui-plugin>

<script>
PLUGIN('report', function(exports) {
    exports.ready = function(element) {
        console.log(element[0].tagName);
    };
});
// logs: UI-PLUGIN
</script>
config

class:name

Toggles a CSS class on the element 500 milliseconds after the plugin is created.
Reveal the plugin
<ui-plugin path="report" config="class:visible"></ui-plugin>

<script>
PLUGIN('report', function(exports) {});
</script>
config

aclass:true

Adds the value of the path attribute to the element as a CSS class.
Style the plugin by its name
<ui-plugin path="report" config="aclass:true"></ui-plugin>

<script>
PLUGIN('report', function(exports) {});
</script>
Made in Europe