Sorry if this is a common question, but it's driving me nuts. I need to add an actionButton to a Shiny UI that triggers a file save. The actual file save command depends upon which tab of a tabPanel is open, and I can get that information via the tabPanel id. The problem I'm having is with accessing the state of the actionButton and resetting it afterwards.
In ui.r, I have something like this:
shinyUI(fluidPage(
titlePanel("myTitle"),
sidebarLayout(
sidebarPanel("",
actionButton("save", "Save File"),
# test to make sure the button is working
verbatimTextOutput("sb") # it increments when clicked
)
)
))
In server.r, I'm trying to do this:
shinyServer(function(input, output) {
# test to make sure the button is working
output$sb <- renderPrint({ input$save }) # increments when clicked
# here is the problem code:
if(input$save > 0) { # button was clicked, so...
input$save <- 0 # reset the flag
print("HERE") # and do something else
}
})
Of course, I'll check the status of the tabPanel instead of printing "HERE", which will likely generate another question if I get past this problem. How do I access and change the value of input$save in the server.r code? There is no evidence that the code inside the if() conditional statement is being executed, so I assume that the logical test is either not being performed, or is returning FALSE even though the value of input$save increments whenever the button is clicked.
Thanks for any advice. As is probably apparent, I'm very new to Shiny and am finding it rather opaque, so far.
Best, --Mike C.