Yang-Tang / shinyjqui

jQuery UI Interactions and Effects for Shiny
https://yang-tang.github.io/shinyjqui/
Other
273 stars 32 forks source link

hide div() from start #15

Closed systats closed 6 years ago

systats commented 6 years ago

Hi folks, really great shiny package :) Do you know how to hide a div() element in the UI from the start on and show it later by jqui_show (like hidden() from shinyjs)?

Thanks in advance, Simon

Yang-Tang commented 6 years ago

Hi @systats , sorry for the late reply. Currently, there is no function like shinyjs::hidden() that can be used to hide an element in the UI at the startup, however, you can use jqui_hide() in the Server to hide a div() like this:

library(shiny)
library(shinyjqui)

ui <- fluidPage(
  actionButton("show", "Show"),
  div(id = "msg", "foo")
)

server <- function(input, output, session) {
  jqui_hide("#msg", effect = "blind")

  observeEvent(input$show, {
    jqui_show("#msg", effect = "blind")
  })
}

shinyApp(ui, server)

The UI version of jqui_hidden() is not hard to implement. If you really need it, I can add it into the update list of the next version :)

systats commented 6 years ago

Thanks, works perfectly fine!