It will only append the first time I click because input$shinyalert
is TRUE
after I hit okay. Is there a way to reset the input for shinyalert
so that it will re-trigger my observe when I hit action button the second/third.. time in a session.
I tried to assign NULL
/FALSE
/0
to input$shinyalert
(input$shinyalert <- NULL
) but it gave me this error.
Warning:
Error in $<-.reactivevalues:
Attempted to assign value to a read-only reactivevalues object
Here is my code
# observe event for my action button
observeEvent(input$action, {
shinyalert("","Are you sure?", type="warning", showCancelButton = TRUE)
})
observe({
req(input$shinyalert)
isolate({
newrow <- data.frame(a = "fisrt",
b = "second",
c = "third")
# appending to mytable in SQL server
dbWriteTable(conn, "mytable", newrow, append = TRUE)
})
})