mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Make a macro for the AJAX update module
This is less repetitive than typing out the HTML with all its attributes every time. It also lets us wrap up the idea of ‘finished’ as a parameter, so the AJAX code will only be initiated when it’s needed, eg if a job is still processing.
This commit is contained in:
15
app/templates/components/ajax-block.html
Normal file
15
app/templates/components/ajax-block.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{% macro ajax_block(url, key, interval=2, finished=False) %}
|
||||
{% if not finished %}
|
||||
<div
|
||||
data-module="update-content"
|
||||
data-resource="{{ url }}"
|
||||
data-key="{{ key }}"
|
||||
data-interval-seconds="{{ interval }}"
|
||||
aria-live="polite"
|
||||
>
|
||||
{% endif %}
|
||||
{{ caller() }}
|
||||
{% if not finished %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
Reference in New Issue
Block a user