Created
September 10, 2020 16:34
-
-
Save MayaGans/f82ad8dbe7480d844d2a2b8c1e5afd74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
source("parent_module.R") | |
source("child_module.R") | |
ui <- fluidPage( | |
parent_mod_ui("parent") | |
) | |
server <- function(input, output) { | |
callModule(parent_mod_srv, "parent") | |
} | |
shinyApp(ui = ui, server = server) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
child_mod_ui <- function(id) { | |
ns <- NS(id) | |
tagList( | |
sliderInput(ns("the_slider"), "SLIDE", min = 0, max = 10, value = 3) | |
) | |
} | |
child_mod_srv <- function(input, output, session) { | |
ns <- session$sn | |
observeEvent(input$the_slider, { | |
if (input$the_slider > 5) shinyjs::disable("parent-toggle_disable") | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parent_mod_ui <- function(id) { | |
ns <- NS(id) | |
actionButton(ns("click_me"), "CLICK ME") | |
} | |
parent_mod_srv <- function(input, output, session) { | |
ns <- session$ns | |
observeEvent(input$click_me, { | |
showModal( | |
modalDialog( | |
title = "This is a modal", | |
footer = actionButton(ns("toggle_disable"), "CLOSE MODAL"), | |
child_mod_ui(ns("child")) | |
) | |
) | |
}) | |
observeEvent(input$click_me, { | |
callModule(child_mod_srv, "child") | |
}) | |
observeEvent(input$toggle_disable, { | |
removeModal() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment