From 51021d8057d809fa115da84b29fc2204c1aa2cac Mon Sep 17 00:00:00 2001 From: pvictor Date: Thu, 24 Nov 2022 17:39:16 +0100 Subject: [PATCH] update_variables only bind content of the table --- R/update-variables.R | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/R/update-variables.R b/R/update-variables.R index 399a52a..676e086 100644 --- a/R/update-variables.R +++ b/R/update-variables.R @@ -135,7 +135,7 @@ update_variables_server <- function(id, data, height = NULL) { # variables <- set_input_checkbox(variables, ns(paste("selection", tok, sep = "-"))) variables <- set_input_text(variables, "name", ns(paste("name", tok, sep = "-"))) variables <- set_input_class(variables, "class", ns(paste("class_to_set", tok, sep = "-"))) - update_variables_reactable(variables, height = height) + update_variables_reactable(variables, height = height, elementId = ns("table")) }) observeEvent(input$validate, { @@ -411,7 +411,7 @@ set_input_class <- function(data, variable, id = "classes", width = "100%") { -update_variables_reactable <- function(data, height = NULL) { +update_variables_reactable <- function(data, height = NULL, elementId = NULL) { if (is.null(height)) { height <- if (NROW(data) > 8) "400px" else "auto" } @@ -435,7 +435,15 @@ update_variables_reactable <- function(data, height = NULL) { striped = TRUE, wrap = FALSE ) - htmlwidgets::onRender(tble, jsCode = "function() {Shiny.bindAll();}") + if (is.null(elementId)) { + htmlwidgets::onRender(tble, jsCode = "function() {Shiny.bindAll();}") + } else { + htmlwidgets::onRender(tble, jsCode = sprintf( + "function() {Shiny.bindAll(document.getElementById('%s'));}", + elementId + )) + } + }