What I want to do is to invoke some action in one module using actionButton placed in another module. However, I don't want to invoke output (chart or sth) but simple GUI which is absolutePanel.
An absolutePanel for some reasons must be placed in body module. I don't think it all has something in common with reactive values etc. since I just need to invoke simple gui part.
I read some post here saying that modules create own namespaces for their elements, which are therefore not meant to be shared with other components. How can I, for example, trigger some action in dashboardBody using actionButton placed in dashboardSidebar ?
Here is my example:
sidebar module:
mod_sidebar_ui <- function(id){
ns <- NS(id)
sidebar = dashboardSidebar(
actionButton(ns("btnX"), "Click me")
)}
mod_sidebar_server <- function(id){
moduleServer(id, function(input, output, session) {
observeEvent(input$btnX, {
shinyjs::toggle(id = "panelX")
})
})
}
body module:
mod_body_ui <- function(id){
ns <- NS(id)
body = bs4Dash::dashboardBody(
shinyjs::useShinyjs(),
# this panel should show up after clicking button from first module
shinyjs::hidden(absolutePanel(id = "panelX",
tagList(shinyWidgets::actionBttn(inputId = "btn11", label = NULL, icon = icon("chart-line")),
shinyWidgets::actionBttn(inputId = "btn22", label = NULL, icon = icon("user-friends")))))
)}
app
app_ui <- function(request) {
tagList(
golem_add_external_resources(),
bs4Dash::dashboardPage(
header = bs4Dash::dashboardHeader(),
mod_sidebar_ui("sidebar_ui"),
mod_body_ui("body_ui")
))
}