ebailey78 / shinyBS

Twitter Bootstrap Components for Shiny
182 stars 47 forks source link

Can't attach a popover to an input generated via renderUI #4

Closed ThomasSiegmund closed 10 years ago

ThomasSiegmund commented 10 years ago

Maybe I'm missing something here, but I've tried addPopover and bsPopover. Both don't work for me on inputs made with renderUI:

library(shiny)
library(shinyBS)
runApp(
    list(
        ui = bootstrapPage(
            uiOutput("textInputViaUiOutput"),
            textOutput("textoutput1"),
            textInput(inputId = "textInput2", label = "Popover works"),
            textOutput("textoutput2"),
            bsPopover(id = "textInput2", title = "Test via bsPopover", "adding a popover to an input defined in ui.R works fine.")
        ),
        server = function(input, output, session) {

                output$textInputViaUiOutput <- renderUI({
                    textInput(inputId = "textInput1", label = "Popover broken");    
                })
                addPopover(session, id = "textInput1", title = "Test via addPopOver", "can't make it work with input defined in server.R");

                output$textoutput1 <- renderText(input$textInput1);
                output$textoutput2 <- renderText(input$textInput2);

            }
        )
)
ebailey78 commented 10 years ago

Okay, I think I have this one fixed... It is happening because shiny hasn't rendered the ui element yet when addPopover is called. I've added a 100ms pause to addPopover to give shiny a chance to render the element before it tries to add the popover. It seems to work in your provided example... I will include this change in the next release...

ebailey78 commented 10 years ago

I'm going to close this issue, If you still have problems let me know.