*update
*update refreshes a target Sercrod host after the current
host or element updates. It is the preferred name for this behavior.
*updated-propagate remains available as a compatibility alias.
The value is a literal routing spec, not a JavaScript expression.
Use root, a numeric Sercrod-host depth, or a selector.
Parent refresh example
<serc-rod id="parent" data='{"message":"parent_message"}'>
<serc-rod data='{"child_message":"hello"}'>
<button
@click="$parent.message = child_message"
*update="2">
Send to parent
</button>
</serc-rod>
<p *print="message"></p>
</serc-rod>
Here the button is inside the child Sercrod host. The nearest host is
1, and the parent host is 2. After the click
changes parent data, *update="2" refreshes the parent view.
Numeric rule
- Numbers count Sercrod hosts only.
- Normal elements such as
div,p, andbuttonare skipped. - On a normal element,
*update="1"means the nearest containing Sercrod host. - On a Sercrod host itself,
*update="1"means that host itself.
More detail
*update can be written on a Sercrod host or on an
ordinary element inside a host. It runs after *updated
on the same host or element.
*updatewith no value is treated as1.*update="root"refreshes the outermost Sercrod host.*update="2"refreshes the second Sercrod host found while walking outward.*update="(#parent)"refreshes the closest Sercrod host matching the selector.- The value is literal; it is not evaluated as JavaScript.
For older templates, *updated-propagate and
n-updated-propagate remain compatibility aliases. New
templates should prefer *update.