タブをクリックすると、flexdashboardのサイドバーを更新しようとしています。それを機能させることはできません。
---
title: "Test Sidebar"
output:
flexdashboard::flex_dashboard:
orientation: rows
runtime: shiny
---
```{r setup}
library(flexdashboard)
library(shiny)
library(shinyjs)
useShinyjs(rmd = TRUE)
```
Sidebar {.sidebar data-width=250}
=======================================================================
```{r}
div(id = "one", selectInput("input1",label= "Show Always",choices=c("a","b","c")))
div(id = "two",selectInput("input2",label = "Show only on Tab 1", choices=c("d","e","f")))
```
<!-- Update the sidebar based on the tab chosen. Generated HTML code shown for tabs-->
Tab 1 <!-- <a href="#section-tab-1" aria-expanded="true" data-toggle="tab"> -->
=======================================================================
```{r}
useShinyjs(rmd = TRUE)
shinyjs::onclick("#section-tab-2",shinyjs::hide(id = "two"))
shinyjs::onclick("#section-tab-1",shinyjs::show(id = "two"))
```
Tab 2 <!-- <a href="#section-tab-2" aria-expanded="true" data-toggle="tab"> -->
=======================================================================
```{r}
useShinyjs(rmd = TRUE)
actionButton("hideSlider", "Hide Input Two")
observeEvent(input$hideSlider, {
shinyjs::toggle(id = "two", anim = TRUE)
})
```
actionButton() と observerEvent() で問題なく動作します。任意の提案をいただければ幸いです。