I'm trying to show exit button on every question along with the continue button in docassemble. Continue button is generated by default by docassemble but I want to have the exit button too. I'm aware that it's not possible to have more than one directives with a question but I'm wondering if there's a trick to do it somehow. I've gone through the docs and didn't find anything that could work to show the exit button.
Is it possible?
You could use action buttons
, but you would need to add it to each question
in the YAML. There is no feature for adding additional buttons to every screen in an interview.
code: |
exit_button = [{'action': 'https://docassemble.org', 'label': 'Exit', 'icon': 'sign-out-alt', 'color': 'danger'}]
---
mandatory: True
question: |
Do you like fruit?
yesno: likes_fruit
action buttons:
code: exit_button
---
mandatory: True
question: |
Do you like vegetables?
yesno: likes_vegetables
action buttons:
code: exit_button
---
mandatory: True
question: |
What is your favorite color?
fields:
- Color: favorite_color
action buttons:
code: exit_button
---
mandatory: True
question: Done
action buttons:
code: exit_button
Alternatively, you could create a JavaScript file in the static folder, include it in your interview with features
-> javascript
, and in the JavaScript file you could add a daPageLoad
listener that adds a button to the button <div>
(which you can find at fieldset.da-button-set
).