我试图在服务器端使用updateSelectizeInput将大量地址加载到Rmarkdown格式的Shiny应用程序的selectizeInput框中。一切正常,但是当您选择过滤后的值时,似乎正在重新加载NULL值。这是一个可重现的示例。任何帮助将不胜感激。谢谢!
---
title: "car_example"
output: html_document
runtime: shiny
---
```{r echo=FALSE}
df <- mtcars
output$uiaddress <- renderUI({
selectizeInput(
'address', label = "Address", choices = NULL
)
})
observeEvent(input$address, {updateSelectizeInput(session, 'address',
choices = df$hp, server = TRUE)
})
```
## SelectizeInput
```{r echo=FALSE}
uiOutput("uiaddress")
```
答案 0 :(得分:0)
我能够通过添加ignoreInit并在observeEvent的末尾一次来解决此问题
observeEvent(input$address, {updateSelectizeInput(session, 'address',
choices = df$hp, server = TRUE)
}, ignoreInit = TRUE, once = TRUE)