# update

Source: https://zotonic.com/docs/1337/update

URI: https://zotonic.com/id/1337

Language: en



Updates the content of an HTML element with a template or a literal HTML text.

Example:

```django
<div id="mydiv"><p>Bye Bye.</p></div>
{% button text="hello" action={update target="mydiv" text="<p>Hello World!</p>"} %}
```

When clicked, the contents of the div will be set to the HTML fragment &lt;p>Hello World!&lt;/p>. This replaces any content present.

::: {.note title="Note"}
Use the <a href="/id/doc_template_action_action_update_iframe" class="doc-reference doc-reference-action"><code>action#update_iframe</code></a> action for updating the contents of an `iframe` element.
:::

Another example, now rendering a template:

```django
<ul id="mylist"><li>Some item</li></li>
{% button text="hello" action={update target="mylist" template="_list_item.tpl" id=42} %}
```

This updates the &lt;ul/> with the output of the template \_list\_item.tpl. All arguments to the update action are also arguments to the template.

| Argument     | Description                                                                      | Example                        |
| ------------ | -------------------------------------------------------------------------------- | ------------------------------ |
| target       | The id of the element receiving the rendered HTML.                               | `target="my-view"`             |
| text         | Literal HTML text to be inserted, no escaping will be done.                      | `text="Hello &lt;b>World</b>"` |
| template     | Name of the template to be rendered.                                             | `template="_list_view.tpl"`    |
| include\_all | Add this argument to include all templates with the same name. If not added then the best template will be used. | `include_all`                  |
| catinclude   | Add this argument to use a <a href="/id/doc_template_tag_tag_catinclude" class="doc-reference doc-reference-tag"><code>tag#catinclude</code></a> instead of a normal include of the template. The `id` argument *must* be present for a catinclude to work. | `catinclude id=1`              |

All other arguments are passed as-is to the included template(s).

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1337?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1337?language=en>)
