Hi everyone,
Given that there are frequent questions about a “back” button for oTree, I want to share my simple solution. It uses the bootstrap navigation header bootstrap navigation header and a small chunk of javascript. The bootstrap navbar allows a page to have different tabs. The javascript code enables switching between different tabs when the “back” or “next” button is pressed. Once the navbar is hidden, graphically there is no difference between two html pages in the oTree page sequence and a single html page in the oTree page sequence consisting of two tabs. The crucial differences is however that now users can use the “back” button to review past pages (tabs), which is not possible for two html pages in the oTree page sequence.
Note this
solution works best for instructions and pages without form fields in general.
This is because this solution works soley over HTML/CSS/Javascript. oTree handles
a page consisting of different tabs the same as any other single page, so if
users switch between different tabs, they do not advance in the page sequence. Accordingly,
input through form fields is only saved once users leave the last tab. Similarly,
methods like before_next_page are only triggered once the last “next” button is
pressed, since this is the only proper “next” button.
The solution can be played and downloaded via oTree Hub: https://www.otreehub.com/projects/back-button/. The first app shows the solution with the navbar visible, the second with a hidden navbar. The third app shows a simple application, where the first two tabs can be used as instructions and the last tab consists of a comprehension test. If users fail the test, they are brought back to the beginning of the instructions. The advantage of this solution is that it does not hack the oTree page sequence and does not interfere with any internal process of oTree.
The bootstrap navbar offers further customization and styling, so it’s worth to check the bootstrap documentation. Feedback and comments welcome!
Best,
Luca
--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/91d11858-5aa1-467b-9095-e7595835cf82n%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "oTree help & discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/otree/0UvDG8mhhcs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/dd55820c-4d4c-49c9-bd4d-97f538603431n%40googlegroups.com.