Spanish Total.js
English
Documentation For AI agents
Contents

ui-import

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

.md GitHub
On this page

The <ui-import> element downloads content from your server and inserts it into the page. It uses IMPORT(), described in the Importing content guide together with the flags that the address accepts.

API

property

path="URL"

The address of the content.

The address can carry the flags of IMPORT(), for example /parts/menu.html @prepend. The content is appended to the element unless target says otherwise.

Import a part of the page
<ui-import path="/parts/menu.html"></ui-import>
property

config="key:value;key:value"

The options of the import.

The format is the same as in ui-component.

property

plugin="path"

Creates a plugin on the element itself.

The plugin is created ahead of the download, so the imported content can use its path.

Import into a new plugin
<ui-import path="/parts/form.html" plugin="myform"></ui-import>

<script>
PLUGIN('myform', function(exports) {
    console.log('plugin', exports.path.toString());
});
// logs: plugin myform
</script>
config

url:address

The address of the content, used when the path attribute is empty.
Set the address in the configuration
<ui-import config="url:/parts/footer.html"></ui-import>
config

target:selector

Inserts the content into another element.
Choose where the content goes
<div id="content"></div>
<ui-import path="/parts/news.html" config="target:#content"></ui-import>
config

path:value

Replaces the keywords ~PATH~ and CLASS in the imported content.

The value is also added to <ui-plugin> elements without a path attribute, and given as the name to a PLUGIN(function(... declaration without a name.

Reuse one part with different paths
<ui-import path="/parts/item.html" config="path:orders;id:o1"></ui-import>
config

id:value

Replaces the keyword ~ID~ in the imported content.
config

init:path

Calls a function when the content is in the page.

A value that starts with ? refers to the closest plugin of the target element.

Run code after the import
<ui-import path="/parts/chart.html" config="init:FUNC.imported"></ui-import>

<script>
FUNC.imported = function() {
    console.log($('ui-import canvas').length);
};
// logs: 1
</script>
config

class:name

Toggles a CSS class on the target element when the content is in the page.
Mark the element as loaded
<ui-import path="/parts/text.html" config="class:loaded"></ui-import>
Made in Europe