if (interactive()) {
library(shiny)
library(shinyCohortBuilder)
shiny::addResourcePath(
"shinyCohortBuilder",
system.file("www", package = "shinyCohortBuilder")
)
ui <- fluidPage(
tags$head(
shiny::tags$script(type = "text/javascript", src = file.path("shinyCohortBuilder", "scb.js"))
),
actionButton("update", "Update with random value"),
div(
class = "cb_container",
`data-ns_prefix` = "",
div(
class = "cb_step",
`data-step_id` = "1",
div(
class = "cb_filter",
`data-filter_id` = "filid",
.cb_input(
numericInput("val", "Value", value = 1),
data_param = "range"
)
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$action, {
# print should be avoided when value is changed due to update
print(input$action)
})
observeEvent(input$update, {
updateNumericInput(session, "val", value = rnorm(1))
})
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab