I use the function flipBox from shinydashboardPlus to create flip box and I add a button. The user have to clik on it to flip the box. But the box also flip when we click on it and I would like to desactive it I mean prevent fliping by cliking on the box (the box must flip only when we click on the button). This is what I did :
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
shinyApp(
ui = dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
actionButton("swich_id", "click to swich"), # click on the button to flip the box
flipBox(
id = "id1",
front = div(
class = "text-center",
height = "300px",
width = "100%",
h1("A"),
p("a table"),
DT::DTOutput('mytable')
),
back = div(
class = "text-center",
height = "300px",
width = "100%",
h1("B"),
p("a graphe"),
plotOutput("graph")
)
)
)
),
server = function(input, output, session) {
output$mytable <- DT::renderDT({
cars[1:5, 1:2]
})
output$graph <- renderPlot({
plot(cars$speed, cars$dist)
})
observeEvent(input$swich_id, {
updateFlipBox("id1")
})
}
)
Some help would be appreciated
There is no official way to do so. We need to have our own custom hacky way to change the source code of
flipBox.flipBoxfunction. Here we add one more optiontrigger = c("click", "hover", "disable")to allow us to choose methods other thanclickorhover.tags$script.shinyjsto manually flip the box when the button is clicked.