title: Update conditional panels using action buttons
body: <p>I would like to be able to change conditional panels in R shiny using an actionButton. Reading through related questions I came up with the following example. That doesn't work! But I can't figure out why.</p>
  
  <p>App code:</p>
  
  <pre><code>ui = fluidPage(
  
    conditionalPanel('output.CP_Flag == "1"', 'Condition met'),
  
    conditionalPanel('output.CP_Flag == "2"', 'Special case: Flag == 2'),
  
    conditionalPanel('output.CP_Flag != "1"', 'Condition not met'),
  
    selectInput(inputId = 'Selection',
                label = 'Select value, 1 meets the condition',
                choices = 1:10),
  
    actionButton(inputId = 'Change_Panel',
                 label = 'Change Panel')
  
  )
  server = function(input, output, session) {
  
    CP_Flag = reactive({CP$Flag})
    output$CP_Flag = renderText({CP_Flag()})
    outputOptions(output, 'CP_Flag', suspendWhenHidden=FALSE)
  
    observeEvent(input$Change_Panel, Fn_CP_Function(as.numeric(input$Selection)))
  
  }
  
  shinyApp(ui, server)
  </code></pre>
  
  <p>Supporting code:</p>
  
  <pre><code>CP = new.env(parent = emptyenv())
  
  CP$Flag = 2
  
  Fn_CP_Function = function(i){
    CP$Flag = i
  }
  </code></pre>
  
  <p>It's not an issue with format e.g. numeric vs. character, or with an inconsistent number of quotation marks because changing CP$Flag in R itself produces the result I would expect. It's just that the actionButton has no effect.</p>
  
  <p>I'd be grateful for either (a) any insights into why this isn't working or (b) a code snippet that achieves the goal: updating conditional panels based on clicks of actionButtons.</p>