Skip to content

Instantly share code, notes, and snippets.

@geebioso
Last active October 2, 2019 22:40
Show Gist options
  • Save geebioso/9dce29fbd1ca06b33bc1e6b890d744ff to your computer and use it in GitHub Desktop.
Save geebioso/9dce29fbd1ca06b33bc1e6b890d744ff to your computer and use it in GitHub Desktop.
library(shiny)
library(shinyjs)
mod1UI = function(id){
ns = NS(id)
fluidRow(
shinyjs::useShinyjs(),
actionButton('show', 'Show'),
actionButton('hide', 'Hide'),
# shinyjs::hidden(
div(id = "div1",
h4("Div to Hide/show")
)
# )
)
}
mod1 = function(input, output, session){
ns = session$ns
observeEvent(input$show, {
shinyjs::show(ns('div1'))
})
observeEvent(input$hide, {
shinyjs::hide(ns('div1'))
})
}
ui <- fluidPage(
mod1UI('mod1')
)
server <- function(input, output, session){
callModule(mod1, 'mod1')
}
# Run the application
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment