R Shiny - Passing selectizeInput as argument to ShinyModule

44 Views Asked by At

This is my Code for the Server function:

dragularServer <- function(id, input_col) {​​​​​
  moduleServer(
    id,
    function(input, output, session = getDefaultReactiveDomain()) {​​​​​
   
      output$elementsInput <- renderUI({​​​​​
        lapply(input_col, function(x) tags$div(class="inlinedisplay", drag = x, x))
      }​​​​​)
   
    }​​​​​
  )
}​​​​​

I want to pass the values from the selectizeinput to the function.

selectizeInput("columns_1", "Relevant vars", choices = unique(data$var), selected = c("Tradition"), multiple = T)

## Übergabe
dragularServer("id_1", input_col = input$columns_1)

The data gets passed ONCE (on load) correctly, but does not react to any changes. Can anyone explain this behaviour? Does it have something to do with the namespace?

1

There are 1 best solutions below

3
On BEST ANSWER

Your input into dragularServer is just a value and not a reactive, so it gets only passed once on startup. To make it reactive, use reactive({input$columns_1}) and adapt your code in the server to deal with reactive values, i.e. input_col()