Good morning,
I am very new to shiny modules and finally have been able to pass module values between modules. However, I'd like to hide certain parts of the module UI based on what tab the user is on. I can do this when I don't use modules as shown below.
checkboxInput(inputId = "parGlobal_hideNarrative", label = "HIDE NARRATIVE"),
sidebarMenu(
id= "smID",
menuItem("Home", tabName = "tn_homePage")
observe({
if(input$smID == "tn_homePage") # it requires a sidebarMenu ID to reference it
{shinyjs::hide("parGlobal_hideNarrative")}
else {shinyjs::show("parGlobal_hideNarrative")}
})
However, I can't seem to reference the module components like the above solution.
#First successful module!
modUI_parGlobalSchsacRegionChbCounty(id = "parGlobal", df_mnRegionChbCounty),
shinydashboard::sidebarMenu(
id= "smID", #By having sidebarMenu id, I can reference it and hide other filters with shinyjs
module UI modUI_parGlobalSchsacRegionChbCounty <- function(id, df) {
ns <- NS(id)
tagList(
#Check box will be used on every tab to hide some sort of narrative
checkboxInput(ns("parGlobal_hideNarrative"), label = "HIDE NARRATIVE"),
selectInput(
ns("parGlobal_county"),
label= "Select County",
choices= sort(unique(df$county)),
selected= "Kittson",
multiple= FALSE,
width= 350
),
selectInput(
ns("parGlobal_schsacRegion"),
label= "Select SCHSAC Region",
choices= NULL,
selected= NULL,
multiple= FALSE,
width= 350
),
selectInput(
ns("parGlobal_chb"),
label= "Select Community Health Board",
choices= NULL,
selected= NULL,
multiple= FALSE,
width= 350
)
)
}
observe({
if (input$smID == "tn_home" )
{
shinyjs::hide("parGlobal-parGlobal_schsacRegion-selectized")
}
else
{
shinyjs::show("parGlobal-parGlobal_schsacRegion-selectized")
}
})
The reason I was hoping the above worked is this is the tabindex id as shown in the image.
Is there a way to easily hide and show module UI elements based on the user's selections? Like can I give the Module an ID and then reference each component? I was hoping for a syntax like parGlobal$parGlobal_shcsacRegion but this doesn't seem to work.
Thank you