I'm building a R Shiny dashboard, and am trying to implement conditionalPanels. Granted, I'm new to JavaScript. There's plenty of posts on SO about conditionalPanels
, but every single one I've seen uses input.something
in its condition expression, typically like this:
conditionalPanel(
condition = "input.tabs == 'correlation'",
actionButton("generate_correlation", "Generate Heat Map")
)
I know that the expression inside the condition statement is a string that is evaluated as a JavaScript expression, but I'm wondering if it's possible to access other variables and objects beyond input
? Can it evaluate reactive functions, for instance? I would like to have a button be pressed, and then a new tab conditionally appear as a result. I've create
tabPanel("Tab 1",
actionButton("dropColumnsComplete", "Next"))
Then, I've created a reactive expression on my server side to handle this:
dropColumnsComplete <- reactive(input$dropColumnsComplete,{
return(TRUE)
})
Clicking the button triggers the input$dropColumnsComplete
event, which should invoke the reactive expression that returns TRUE
when the function dropColumnsComplete()
is called. Then, I add in
conditionalPanel(condition = "dropColumnsComplete()",
tabPanel("Tab 2")
),
and I expect that pressing the button will cause Tab 2 to appear. I know I'm not accessing the dropColumnsComplete()
inside the condition expression correctly- should it be document.dropColumnsComplete()
? shiny.dropColumnsComplete()
? There's a surprising lack of documentation on this, so I'm at a loss for how to access variables beyond input$...
within JavaScript.