I have a simple user interface that asks two questions and takes two user defined values as responces. I have implmented this using the latest version of shinyalert
using the new features that allow input controls to be defined in the modals. An example of the process is shown here:
library(shiny)
library(shinyalert)
ui <- fluidPage(
useShinyalert(),
tags$h2("Demo shinyalert"),
tags$br(),
fluidRow(
column(
width = 6,
actionButton("shinyalert_popup",
"Alert Popup")
)
),
fluidRow(
verbatimTextOutput(outputId = "return_value_1"),
verbatimTextOutput(outputId = "return_value_2")
)
)
server <- function(input, output, session) {
observeEvent(input$shinyalert_popup, {
shinyalert(
title = "Input Number 1",
text = tagList(
"Enter a number",
textInput(inputId = "shinyalert_value_1",
label = "")
),
html = TRUE,
inputId = "shinyalert_modal",
showConfirmButton = TRUE,
confirmButtonText = "OK",
callbackR = function() {
shinyalert(
title = "Input Number 2",
text = tagList(
"Enter another number",
textInput(inputId = "shinyalert_value_2",
label = "")
),
html = TRUE,
inputId = "shinyalert_callback",
showConfirmButton = TRUE,
confirmButtonText = "OK"
)
}
)
})
output$return_value_1 <- renderPrint(input$shinyalert_value_1)
output$return_value_2 <- renderPrint(input$shinyalert_value_2)
}
shinyApp(ui = ui, server = server)
The responce shows that the first input, from the id shinyalert_value_1
is captured and updates in the ui. The second input, from shinyalert_value_2
, which is nested in the callbackR
parameter shows a NULL
when values are typed and after the modal has been closed. This indicates that the input$shinyalert_value_2
is not found in this configuration.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4