2017-08-11 153 views
1

我爲textInput調用了閃亮的removeUi(),但是隻有輸入部分被刪除而不是標籤。請參見下面的代碼和圖像:R閃亮刪除UI保留標籤

clearElements <- function (dat) { 
    observe({ 
     for (el in dat) { 

     id <- strsplit(el,substring(el, nchar(el)-8, nchar(el)))[[1]] 
     print(id) 
     removeElement(id) 
     } 
    }) 
    } 

    removeElement <- function (el_id) { 
     removeUI(
     selector = paste0("#", el_id), 
     multiple = TRUE, 
     immediate = TRUE, 
     session 
    ) 
    } 

這裏是視覺效果: enter image description here

回答

-1

幾個元件被包裹在div秒。試試這個:

removeElement <- function (el_id) { 
    removeUI(
     selector = paste0("div:has(> #", el_id, ")") 
    ) 
    } 
+0

這並不實際工作.. – snowgage

1

接受的答案不起作用。

您需要刪除整個.shiny輸入容器像下面

removeUI(
    selector = sprintf('.shiny-input-container:has(#%s)',el_id) 
)