0

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?

Data Mastery
  • 1,555
  • 4
  • 18
  • 60

1 Answers1

1

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()

starja
  • 9,887
  • 1
  • 13
  • 28
  • thank you, that works. Without modules, I don´t have to wrap them in a reactive expression, why it this necessary in this case? I expected it to be some kind of Namespace problem... – Data Mastery Dec 07 '20 at 14:07
  • 1
    yeah, I'm not entirely sure. My guess is that it has to do with how the reactive values are registered. If I recall correctly, it also works to pass the complete `input` object (as is, without a `reactive`) to the module and then just in the module use `input_col[["columns_1]]`. Maybe I can do more digging later – starja Dec 07 '20 at 14:10
  • ok, at least it works, fair enough :-). Thank you for your help – Data Mastery Dec 07 '20 at 14:12