简体   繁体   中英

R Shiny - Passing selectizeInput as argument to ShinyModule

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?

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, ie input_col()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM