You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article on building a dynamic UI suggests that one way to pass values to a conditionalPanel is to use an output variable. The example given below shows this only works if that variable is also rendered elsewhere in the UI - the JavaScript does not seem to have access to the value if it is not also rendered.
The example given in the SO question shows the use-case of encapsulating a selectize input within a module, but here is a more minimal example:
library(shiny)
ui <- shinyUI(fluidPage(
## Uncomment the following line and the first condition will evaluate TRUE
#textOutput('selected'),
conditionalPanel(condition = "output.selected == 'Option one'", p('Option one is selected.')),
conditionalPanel(condition = "output.selected != 'Option one'", p('Option one is NOT selected.'))
))
server <- shinyServer(function(input, output, session) {
output$selected <- renderText('Option one')
})
shinyApp(ui = ui, server = server)
The text was updated successfully, but these errors were encountered:
Right--we don't, by default, calculate/render output values if they aren't going to be visible. And if we don't calculate them, you can't use them in conditions.
You can change this behavior this by setting an output to calculate every time, you can use this in your server.R (replace outputId with the corresponding value):
Following up on my own Stack Overflow question.
This article on building a dynamic UI suggests that one way to pass values to a conditionalPanel is to use an
output
variable. The example given below shows this only works if that variable is also rendered elsewhere in the UI - the JavaScript does not seem to have access to the value if it is not also rendered.The example given in the SO question shows the use-case of encapsulating a selectize input within a module, but here is a more minimal example:
The text was updated successfully, but these errors were encountered: