Pareto
Pareto

Reputation: 179

ShinyAlert in Rmd Flexdashboard

I am trying to render a popup in an Rmd flexdashboard.

Here is my code:

---
title: "Test"
output: flexdashboard::flex_dashboard
runtime: shiny
---

```{r global, include= FALSE}
library(shinyalert)
```


```{r}
  useShinyalert(  )
  actionButton("helpBtn", "Help")
```


```{r}
  observeEvent(input$helpBtn, {
  shinyalert(title = "Help Me!", text = "Please contact your instructor")})

```

The button shows up but when clicked it does not show the popup. Any ideas?

Upvotes: 3

Views: 500

Answers (2)

Angus Watters
Angus Watters

Reputation: 21

Not sure if your issue was resolved or not, but setting the rmd parameter in useShinyalert to TRUE should solve your problem.

useShinyalert(rmd = TRUE)

Upvotes: 1

cwthom
cwthom

Reputation: 393

I've been having the same issue, and I don't think you can do this with shinyalert because of the need for useShinyAlert() - adding extra dependencies into Rmd documents doesn't seem to be supported very well.

A workaround is to use sendSweetAlert from the shinyWidgets package:

---
title: "Test"
output: flexdashboard::flex_dashboard
runtime: shiny
---

```{r global, include= FALSE}
library(shinyWidgets)
```


```{r}
  actionButton("helpBtn", "Help")
```


```{r}
  observeEvent(input$helpBtn, {
  sendSweetAlert(session, title = "Help Me!", text = "Please contact your instructor")})

```

Upvotes: 4

Related Questions