R/update-shiny-material-date-picker.R

Defines functions update_material_date_picker

Documented in update_material_date_picker

#' Change the value of a material_date_picker on the client
#'
#' Change the value of a material_date_picker on the client.
#' @param session The session object passed to function given to shinyServer.
#' @param input_id The input_id of the material_date_picker.
#' @param value The value to set for the material_date_picker (format 'mmm dd, yyyy').
#' @seealso \code{\link{material_date_picker}}
#' @examples
#' \dontrun{
#' update_material_date_picker(
#'   session,
#'   input_id = "example_date_picker",
#'   value = "Apr 10, 2012"
#' )
#' }
update_material_date_picker <- function(session, input_id, value = NULL){
  if(is.null(value)) {
    return(NULL)
  }
  session$sendCustomMessage(
    type = "shinymaterialJS",
    paste0(
        "$('#", input_id, "').val('", value, "');Shiny.onInputChange('", input_id, "', '", value, "');"
    )
  )
}

Try the shinymaterial package in your browser

Any scripts or data that you put into this service are public.

shinymaterial documentation built on Sept. 1, 2020, 1:07 a.m.