Created
April 16, 2019 13:29
-
-
Save bjcairns/c35e51d0d617acf34d786edb5cfa173e to your computer and use it in GitHub Desktop.
Add a button to a learnr tutorial (or other pre-rendered Shiny document) to stop Shiny
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Stop learnr tutorial with a button" | |
output: learnr::tutorial | |
runtime: shiny_prerendered | |
--- | |
```{r setup, include=FALSE} | |
library(learnr) | |
knitr::opts_chunk$set(echo = FALSE) | |
``` | |
## Stop the tutorial | |
Click the button below to stop the tutorial. Note that in the first chunk, `context="render"` is redundant because `"render"` is the default context. | |
```{r, context="render"} | |
actionButton("stopapp", "Stop tutorial") | |
``` | |
```{r, context="server"} | |
observeEvent(input$stopapp, stopApp()) | |
``` | |
See [RMarkdown help on Pre-rendered Shiny Documents](https://rmarkdown.rstudio.com/authoring_shiny_prerendered.html) for more information. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment