Why when I click the "Next" button and then return to the first screen using the "Back" button, the condition works and I can't go forward until I click in at least one option, but the first time it does not work that way?
Explanation
I use insertUI() with a glide() inside it in the server function. To create the first screen of the glide I use screenOutput() and since shinyglide use the same syntax as conditionalPanel() the next_condition parameter is based in this conditionalPanel() example.
Code
# libraries
library(shiny)
library(shinyglide)
library(shinyjs)
# ui
ui <- fluidPage(useShinyjs(),
tags$div(id = 'placeholder'),
actionButton("btn",
"button"))
# server
server <- function(input, output, session) {
# insertUI() when btn is clicked
observeEvent(input$btn, {
disable("btn")
insertUI(selector = '#placeholder',
ui = tags$div(fixedPage(
glide(
id = "glide",
screenOutput(outputId = "screen",
next_condition = "output['next_condition'] == 1"),
screen(p("Second screen."))
)
)))
})
# screenOutput() for the first screen
output$screen <- renderUI({
checkboxGroupInput("checkbox", "checkbox", list("A", "B"))
})
# condition to shinyglide works
outputOptions(output, "screen", suspendWhenHidden = FALSE)
# output variable in the server code that is used in argument 'next_condition' in screenOutput()
output$next_condition <- reactive({
if (isTruthy(input$checkbox)) {
1
} else {
0
}
})
# condition to output works
outputOptions(output, "next_condition", suspendWhenHidden = FALSE)
}
shinyApp(ui, server)
Hi, thanks for this package. It's amazing!
Questions
Explanation
I use insertUI() with a glide() inside it in the server function. To create the first screen of the glide I use screenOutput() and since shinyglide use the same syntax as conditionalPanel() the next_condition parameter is based in this conditionalPanel() example.
Code