Search code examples
user-interfaceshinyuser-experienceshinyjsflexdashboard

Go to another page of flexdashboard on click shiny actionbutton


I have following code in my test.Rmd.

---
title: "Test Application"
runtime: shiny
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
---

sidebar {.sidebar}
==========================

Controllers
-----------------------
```{r}
actionButton("clickMe", label = "Click Me", class = "btn btn-lg btn-primary")
```

Page1
========================

Page2
=======================

Initially, my app is on Page 1. I want to take my app to Page2 on clicking the button clickMe. Please help me with this..!


Solution

  • You can use the onClick argument like this:

    actionButton("clickMe", label = "Click Me", class = "btn btn-lg btn-primary", 
                 onclick="location.href='#section-page2';")