Learn R Programming

shinyMobile (version 0.5.0.9000)

updateF7Toggle: Change the value of a toggle input on the client

Description

Change the value of a toggle input on the client

Usage

updateF7Toggle(session, inputId, checked = NULL, color = NULL)

Arguments

session

The session object passed to function given to the server.

inputId

The id of the input object.

checked

Whether the toggle is TRUE or FALSE.

color

Toggle color.

Examples

Run this code
# NOT RUN {
if (interactive()) {
 library(shiny)
 library(shinyMobile)

 shinyApp(
   ui = f7Page(
     title = "My app",
     f7SingleLayout(
       navbar = f7Navbar(title = "updateF7Toggle"),
       f7Card(
         f7Button(inputId = "update", label = "Update toggle"),
         f7Toggle(
           inputId = "toggle",
           label = "My toggle",
           color = "pink",
           checked = FALSE
         ),
         verbatimTextOutput("test")
       )
     )
   ),
   server = function(input, output, session) {

     output$test <- renderPrint({input$toggle})

     observeEvent(input$update, {
       updateF7Toggle(
         session,
         inputId = "toggle",
         checked = TRUE,
         color = "green"
       )
     })
   }
 )
}
# }

Run the code above in your browser using DataLab