ui-plugin
The attributes and the config keys of the ui-plugin element.
On this page
API
property
path="path"
The path of the plugin model, and the name of the declaration to use.
path="path"The attribute accepts these forms:
| Value | Model path | Declaration |
|---|---|---|
orders | orders | orders |
target name | target | name |
? name | a generated path under jComponent.data. | name |
* | common | PLUGIN('*', ...) |
| no attribute | the name of the next declaration waiting for an element | that declaration |
When no declaration exists for the path, the element still works as a plugin without its own code.
<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>
<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.
config="key:value;key:value"The format is the same as in ui-component. Besides the keys below, the plugin reads any key of its own from exports.config.
<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.
init:pathThe 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.
<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.
class:name<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.
aclass:true<ui-plugin path="report" config="aclass:true"></ui-plugin>
<script>
PLUGIN('report', function(exports) {});
</script>