Directory input not working after insertUI - RShiny

I implement an RShiny app where the user has to click a button (extract_btn). After this happens, an HTML page is created dynamically. And here comes the problem. When I insert a shinyDirButton with insertUI, the directories don't show up. While inspecting the site the konsole show up this problem:




ui <- shinyUI( fluidPage( theme = "bootstrap.css", 
                          fluidRow(id="first_view", style="display:;",
                                            inputId = "extract_btn", label = HTML("<b>Extract</b>"),
                                            class = " action_button img-circle")
                          shinyDirButton(id = "dir", label = "Choose directory", "Select PDF-File")


server <- function(input, output, session) {
  current <- reactiveValues(page="first_view")
  observeEvent(input$extract_btn, {
      selector = paste("#", current$page,sep = ""),
      where = "afterEnd",
      ui = Render_ExtractPage()
    removeUI(selector = paste("#", current$page,sep = ""))
    current$page <- "extract_view"
  # dir
  roots <- getVolumes()  
  shinyDirChoose(input, id = "dir", roots = roots,filetypes = c('', 'pdf'), session=session)
  dir <- reactive(input$dir)
  # path
  path <- reactive({
    file.path(paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep))
  Render_ExtractPage <- function() {
    shinyDirButton(id = "dir", label = "Choose directory", "Select PDF-File")   

shinyApp(ui = ui, server = server)

I would be very grateful for any help.

Hi @Livruen,
This might be better suited to the #shiny channel! I can't move posts (i'm not an admin), but you can move it (since it's yours).

Here's an excellent illustrated explanation how from the Discourse site

Thank you ! I will do that :slight_smile: