-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp2.R
More file actions
48 lines (32 loc) · 1.54 KB
/
app2.R
File metadata and controls
48 lines (32 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
library(shiny)
library(shinyStorePlus)
ui <- fluidPage(
initStore(),
titlePanel("Edit inputs and refresh..."),
tags$h1("Non-Dynamic Input with '*'"),
selectInput("mnth", "Non-dynamic:", choices = c("", month.name), selected = ""),
tags$h1(id="dyn1","Dynamic Input Selected By Full ID name"),
#dyamic input will appear here
tags$h1(id="dyn2","Dynamic Input Selected By 'sampletext*'"),
#dyamic input will appear here
tags$h1(id="dyn3","Dynamic Input Selected By '*sampletext'"),
#dyamic input will appear here
# this won't work because shinyStorePlus does not create the input for you
tags$h2("User created dynamic inputs"),
textInput("ID","Insert an ID"),
actionButton("add", "Add UI")
)
server <- function(input, output, session) {
observeEvent(input$add, { insertUI( selector = "#add", where = "afterEnd", ui = textInput(paste0("random", input$ID), input$ID) ) })
insertUI( selector = "#dyn1", where = "afterEnd", ui = textInput("dynamicinput1", "Dynamic input with id dynamicinput1","Okay" ) )
for(n in letters[1:3])insertUI( selector = "#dyn2", where = "afterEnd", ui = textInput( paste0("sampletext",n), paste0("Dyn input with id sampletext",n),"Hi" ) )
for(n in letters[1:3])insertUI( selector = "#dyn3", where = "afterEnd", ui = textInput( paste0(n,"sampletext"), paste0("Dyn input with id ",n,"sampletext"),"Hi" ) )
# shinyStorePlus
setupStorage(
appId = "appdyn27",
inputs = TRUE,
dyn.inputs = list("dynamicinput1", "*sampletext", "sampletext*"),
session = session
)
}
shinyApp(ui, server)