mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Add placeholder parameter to updateTextInput (#1742)
* add placeholder parameter * add js placeholder code * roxygenize * grunt * fix updateCheckBoxInput not to use placeholder * simply roxygen * add NEWS * revert grunt
This commit is contained in:
2
NEWS.md
2
NEWS.md
@@ -15,6 +15,8 @@ shiny 1.0.3.9000
|
||||
|
||||
* For `conditionalPanel`s, Shiny now gives more informative messages if there are errors evaluating or parsing the JavaScript conditional expression. ([#1727](https://github.com/rstudio/shiny/pull/1727))
|
||||
|
||||
* Addressed [#1738](https://github.com/rstudio/shiny/issues/1738): The `updateTextInput` and `updateTextAreaInput` functions can now update the placeholder. ([#1742](https://github.com/rstudio/shiny/pull/1742))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
* Fixed [#1546](https://github.com/rstudio/shiny/issues/1546): make it possible (without any hacks) to write arbitrary data into a module's `session$userData` (which is exactly the same environment as the parent's `session$userData`). To be clear, it allows something like `session$userData$x <- TRUE`, but not something like `session$userData <- TRUE` (that is not allowed in any context, whether you're in the main app, or in a module) ([#1732](https://github.com/rstudio/shiny/pull/1732)).
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#'
|
||||
#' @template update-input
|
||||
#' @param value The value to set for the input object.
|
||||
#' @param placeholder The placeholder to set for the input object.
|
||||
#'
|
||||
#' @seealso \code{\link{textInput}}
|
||||
#'
|
||||
@@ -34,15 +35,15 @@
|
||||
#' shinyApp(ui, server)
|
||||
#' }
|
||||
#' @export
|
||||
updateTextInput <- function(session, inputId, label = NULL, value = NULL) {
|
||||
message <- dropNulls(list(label=label, value=value))
|
||||
updateTextInput <- function(session, inputId, label = NULL, value = NULL, placeholder = NULL) {
|
||||
message <- dropNulls(list(label=label, value=value, placeholder=placeholder))
|
||||
session$sendInputMessage(inputId, message)
|
||||
}
|
||||
|
||||
#' Change the value of a textarea input on the client
|
||||
#'
|
||||
#' @template update-input
|
||||
#' @param value The value to set for the input object.
|
||||
#' @inheritParams updateTextInput
|
||||
#'
|
||||
#' @seealso \code{\link{textAreaInput}}
|
||||
#'
|
||||
@@ -106,7 +107,10 @@ updateTextAreaInput <- updateTextInput
|
||||
#' shinyApp(ui, server)
|
||||
#' }
|
||||
#' @export
|
||||
updateCheckboxInput <- updateTextInput
|
||||
updateCheckboxInput <- function(session, inputId, label = NULL, value = NULL) {
|
||||
message <- dropNulls(list(label=label, value=value))
|
||||
session$sendInputMessage(inputId, message)
|
||||
}
|
||||
|
||||
|
||||
#' Change the label or icon of an action button on the client
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
\alias{updateTextAreaInput}
|
||||
\title{Change the value of a textarea input on the client}
|
||||
\usage{
|
||||
updateTextAreaInput(session, inputId, label = NULL, value = NULL)
|
||||
updateTextAreaInput(session, inputId, label = NULL, value = NULL,
|
||||
placeholder = NULL)
|
||||
}
|
||||
\arguments{
|
||||
\item{session}{The \code{session} object passed to function given to
|
||||
@@ -15,6 +16,8 @@ updateTextAreaInput(session, inputId, label = NULL, value = NULL)
|
||||
\item{label}{The label to set for the input object.}
|
||||
|
||||
\item{value}{The value to set for the input object.}
|
||||
|
||||
\item{placeholder}{The placeholder to set for the input object.}
|
||||
}
|
||||
\description{
|
||||
Change the value of a textarea input on the client
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
\alias{updateTextInput}
|
||||
\title{Change the value of a text input on the client}
|
||||
\usage{
|
||||
updateTextInput(session, inputId, label = NULL, value = NULL)
|
||||
updateTextInput(session, inputId, label = NULL, value = NULL,
|
||||
placeholder = NULL)
|
||||
}
|
||||
\arguments{
|
||||
\item{session}{The \code{session} object passed to function given to
|
||||
@@ -15,6 +16,8 @@ updateTextInput(session, inputId, label = NULL, value = NULL)
|
||||
\item{label}{The label to set for the input object.}
|
||||
|
||||
\item{value}{The value to set for the input object.}
|
||||
|
||||
\item{placeholder}{The placeholder to set for the input object.}
|
||||
}
|
||||
\description{
|
||||
Change the value of a text input on the client
|
||||
|
||||
@@ -30,12 +30,16 @@ $.extend(textInputBinding, {
|
||||
if (data.hasOwnProperty('label'))
|
||||
$(el).parent().find('label[for="' + $escape(el.id) + '"]').text(data.label);
|
||||
|
||||
if (data.hasOwnProperty('placeholder'))
|
||||
el.placeholder = data.placeholder;
|
||||
|
||||
$(el).trigger('change');
|
||||
},
|
||||
getState: function(el) {
|
||||
return {
|
||||
label: $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(),
|
||||
value: el.value
|
||||
value: el.value,
|
||||
placeholder: el.placeholder
|
||||
};
|
||||
},
|
||||
getRatePolicy: function() {
|
||||
|
||||
Reference in New Issue
Block a user