Cannot hide/ show/ toggle fields in shiny Modal
alon-sarid opened this issue · 2 comments
alon-sarid commented
Hi.
I wish to hide show relevant UI items inside a popout modal, based on the selection of other fields within the modal.
yet shinyjs::hide.shinyjs::show and toggle does not work
example code:
`library(shiny)
ui <- fluidPage(
actionButton("show_modal", "show modal"),
)
server <- function(input, output) {
observeEvent(input$show_modal, {
showModal(
modalDialog(footer = NULL,easyClose = T,
tagList(
fluidRow(
box(status = "primary", width = 6, style = "direction: ltr",
actionButton("toggle_btn", "show or hide second button")
)),
fluidRow(
box(status = "success", width = 6, style = "direction: ltr",
actionButton("box_btn", "btn!")
))
)
))
})
observeEvent(input$toggle_btn, {
shinyjs::toggle("box_btn")
cat("\npresentation button pressed\n")
})
}
shinyApp(ui, server)`
daattali commented
It doesn't look like you loaded shinyjs. useShinyjs()
…On Sun., Dec. 20, 2020, 04:25 alon-sarid, ***@***.***> wrote:
Hi.
I wish to hide show relevant UI items inside a popout modal, based on the
selection of other fields within the modal.
yet shinyjs::hide.shinyjs::show and toggle does not work
example code:
`
library(shiny)
ui <- fluidPage(
actionButton("show_modal", "show modal"),
)
server <- function(input, output) {
observeEvent(input$show_modal, {
showModal(
modalDialog(footer = NULL,easyClose = T,
tagList(
fluidRow(
box(status = "primary", width = 6, style = "direction: ltr",
actionButton("toggle_btn", "show or hide second button")
)),
fluidRow(
box(status = "success", width = 6, style = "direction: ltr",
actionButton("box_btn", "btn!")
))
)
))
})
observeEvent(input$toggle_btn, {
shinyjs::toggle("box_btn")
cat("\npresentation button pressed\n")
})
}
shinyApp(ui, server)
`
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#225>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHIQFFIMZUCN3ESY3BSZADSVW7HFANCNFSM4VC6KIVA>
.
alon-sarid commented
Thanks!
I am sorry for wasting your time.
this works now:
` library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
actionButton("show_modal", "show modal"),
)
server <- function(input, output) {
observeEvent(input$show_modal, {
showModal(
modalDialog(footer = NULL,easyClose = T,
tagList(
fluidRow(
box(status = "primary", width = 6, style = "direction: ltr",
actionButton("toggle_btn", "show or hide second button")
)),
fluidRow(
box(status = "success", width = 6, style = "direction: ltr",
actionButton("box_btn", "Box!")
))
)
))
})
observeEvent(input$toggle_btn, {
shinyjs::toggle("box_btn")
cat("\npresentation button pressed\n")
})
}
shinyApp(ui, server)`