Show exit button along with continue button on question in docassemble

Question:

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?

Asked By: Fumikage Tokoyami

||

Answers:

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).

Answered By: Jonathan Pyle
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.