ui-import
The attributes and the config keys of the ui-import element.
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.
path="URL"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.
<ui-import path="/parts/menu.html"></ui-import>
property
config="key:value;key:value"
The options of the import.
config="key:value;key:value"The format is the same as in ui-component.
property
plugin="path"
Creates a plugin on the element itself.
plugin="path"The plugin is created ahead of the download, so the imported content can use its path.
<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.
url:address<ui-import config="url:/parts/footer.html"></ui-import>
config
target:selector
Inserts the content into another element.
target:selector<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.
path:valueThe 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.
<ui-import path="/parts/item.html" config="path:orders;id:o1"></ui-import>
config
id:value
Replaces the keyword ~ID~ in the imported content.
id:value
config
init:path
Calls a function when the content is in the page.
init:pathA value that starts with ? refers to the closest plugin of the target element.
<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.
class:name<ui-import path="/parts/text.html" config="class:loaded"></ui-import>