mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-18 01:14:52 -05:00
See parent commit for the reason we’re doing this. Currently our AJAX requests only work as `GET` requests. So this commit does a bit of work to make them work as `POST` requests. This is optional behaviour, and will only happen when the element in the page that should be updated with AJAX has the `data-form` attribute set. It will take the form that has the corresponding `id`, serialise it, and use that data as the body of the post request. If not form is specified it will not do the serialisation, and submit as a `GET` request as before.
17 lines
419 B
HTML
17 lines
419 B
HTML
{% macro ajax_block(partials, url, key, interval=2, finished=False, form='') %}
|
|
{% if not finished %}
|
|
<div
|
|
data-module="update-content"
|
|
data-resource="{{ url }}"
|
|
data-key="{{ key }}"
|
|
data-interval-seconds="{{ interval }}"
|
|
data-form="{{ form }}"
|
|
aria-live="polite"
|
|
>
|
|
{% endif %}
|
|
{{ partials[key]|safe }}
|
|
{% if not finished %}
|
|
</div>
|
|
{% endif %}
|
|
{% endmacro %}
|