Compare commits

...

1 Commits

Author SHA1 Message Date
Barbara Borges Ribeiro
ff034c5013 first crack at updating multiple attribute 2016-08-11 22:29:51 +01:00
6 changed files with 33 additions and 11 deletions

View File

@@ -557,12 +557,13 @@ updateRadioButtons <- function(session, inputId, label = NULL, choices = NULL,
#' }
#' @export
updateSelectInput <- function(session, inputId, label = NULL, choices = NULL,
selected = NULL) {
selected = NULL, multiple = NULL) {
choices <- if (!is.null(choices)) choicesWithNames(choices)
if (!is.null(selected))
selected <- validateSelected(selected, choices, inputId)
options <- if (!is.null(choices)) selectOptions(choices, selected)
message <- dropNulls(list(label = label, options = options, value = selected))
message <- dropNulls(list(label = label, options = options,
value = selected, multiple = multiple))
session$sendInputMessage(inputId, message)
}
@@ -574,8 +575,8 @@ updateSelectInput <- function(session, inputId, label = NULL, choices = NULL,
#' version of \pkg{selectize.js})
#' @export
updateSelectizeInput <- function(session, inputId, label = NULL, choices = NULL,
selected = NULL, options = list(),
server = FALSE) {
selected = NULL, multiple = NULL,
options = list(), server = FALSE) {
if (length(options)) {
res <- checkAsIs(options)
cfg <- tags$script(
@@ -587,7 +588,7 @@ updateSelectizeInput <- function(session, inputId, label = NULL, choices = NULL,
session$sendInputMessage(inputId, list(config = as.character(cfg)))
}
if (!server) {
return(updateSelectInput(session, inputId, label, choices, selected))
return(updateSelectInput(session, inputId, label, choices, selected, multiple))
}
value <- unname(selected)
attr(choices, 'selected_value') <- value

View File

@@ -4117,6 +4117,16 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
this.setValue(el, data.value);
}
if (data.hasOwnProperty('multiple')) {
if (data.multiple) {
$(el).attr('multiple', 'multiple');
$(el).next().attr('class', 'selectize-control multi');
} else {
$(el).attr('multiple', '');
$(el).next().attr('class', 'selectize-control single');
}
}
if (data.hasOwnProperty('label')) $(el).parent().parent().find('label[for="' + $escape(el.id) + '"]').text(data.label);
$(el).trigger('change');
@@ -5184,4 +5194,4 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
})();
//# sourceMappingURL=shiny.js.map
//# sourceMappingURL=shiny.js.map
//# sourceMappingURL=shiny.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -87,6 +87,17 @@ $.extend(selectInputBinding, {
this.setValue(el, data.value);
}
if (data.hasOwnProperty('multiple')) {
if (data.multiple) {
$(el).attr('multiple', 'multiple');
$(el).next().attr('class', 'selectize-control multi');
}
else {
$(el).attr('multiple', '');
$(el).next().attr('class', 'selectize-control single');
}
}
if (data.hasOwnProperty('label'))
$(el).parent().parent().find('label[for="' + $escape(el.id) + '"]').text(data.label);