In implementing an advanced shiny popup solution from K. Rohde, I've run into a problem using a navbarPage and tabPanels. Per the linked solution, the following code is in the appropriate tabPanel:
tabPanel("Multiple Locations",
uiOutput("script"),
tags$div(id="garbage"),
...rest of UI...
)
If Multiple Locations
is the only tabPanel, or if navbarPage(selected="Multiple Locations")
is set, everything works wonderfully (I have implemented nearly identically to the example in the linked solution). But if navbarPage(selected="someOtherPanel")
is set, and the user subsequently navigates to the Multiple Locations
tabPanel, the popups show up empty.
I've tried moving the uiOutput("script")
and tags$div(id="garbage")
lines into the other tabPanel (the one that's active on startup), I've tried moving it right under the navbarPage (before any tabPanel elements), and I've tried duplicating it in those locations as well, to no avail. Moving it right under the navbarMenu() appears to insert a div into the menu itself. Here's the setup that works:
ui<-navbarPage(id="page", selected="Multiple Locations",
tags$head(tags$link(href="myfavicon.ico", rel="icon"),
includeCSS("www/style.css"),
tags$script(type="text/javascript", src = "baranim.js")
),
navbarMenu("Explorer",
tabPanel("Single Location",
...UI elements...
),
tabPanel("Multiple Locations",
uiOutput("script"),
tags$div(id="garbage"),
...UI elements...
)
)
)
Though the app is not yet complete, I don't imagine I'll have users starting on the Multiple Locations
tabPanel. But clearly, I'd still like the popups to function.
Many thanks to K. Rohde for the original solution.