zpt
Version:
Zenon Page Templates - JS (ZPT-JS)
70 lines (61 loc) • 2.54 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>ZPT-JS reference - Configuration - target</title>
<script type="module" src="../js/zpt.js"></script>
<script type="text/javascript" src="../lib/syntaxHighlighter/lib.js"></script>
<link rel="stylesheet" type="text/css" href="../docs.css">
<link rel="stylesheet" type="text/css" href="../lib/syntaxHighlighter/theme.css">
</head>
<body>
<div data-use-macro="'page@templates.html'">
<div data-fill-slot="'page-header'">
<h1>ZPT-JS reference - Configuration - target</h1>
<ul>
<li><a href="#syntax">Syntax</a>.</li>
<li><a href="#description">Description</a>.</li>
<li><a href="#examples">Examples</a>.</li>
</ul>
</div>
<article data-fill-slot="'article'">
<h2 data-attributes="id 'syntax'">Syntax</h2>
<pre class="syntax">
target ::= target_element || Array of target_element
target_element ::= a DOM node
</pre>
<h2 data-attributes="id 'description'">Description</h2>
<p>
The <code>target</code> is used to define the node or nodes where ZPT-JS will search its custom attributes in a partial render. As <a href="configuration-root.html">root</a> it can be a simple DOM node or an array of DOM nodes.
</p>
<p>
It is very similar to <a href="configuration-root.html">root</a>. The difference is that <em>targets</em> refers to updates of nodes using partial renders. The first invokation of ZPT-JS needs a <em>root</em> definition.
</p>
<h2 data-attributes="id 'examples'">Examples</h2>
<p>
Using the configuration option:
</p>
<pre class="brush: js; highlight: [18]">
import { zpt } from './zpt-esm.js';
var dictionary = {
...
};
// First execution: render the body
zpt.run({
root: document.body,
dictionary: dictionary
});
[ your code here ]
// Second execution: render only some elements
zpt.run({
command: 'partialRender',
target: [
document.getElementById( 'id1' ),
document.getElementById( 'id2' )
]
});
</pre>
</article>
</div>
</body>
</html>