mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Inputs now always supply a <label> tag with a special CSS class for hiding NULL labels
This helps to simplify the updating logic on the client
This commit is contained in:
@@ -40,7 +40,7 @@ $.extend(selectInputBinding, {
|
||||
}
|
||||
|
||||
return {
|
||||
label: $(el).parent().find('label[for="' + $escape(el.id) + '"]').text(),
|
||||
label: this._getLabelNode(el),
|
||||
value: this.getValue(el),
|
||||
options: options
|
||||
};
|
||||
@@ -123,14 +123,7 @@ $.extend(selectInputBinding, {
|
||||
this.setValue(el, data.value);
|
||||
}
|
||||
|
||||
let escaped_id = $escape(el.id);
|
||||
if (this._is_selectize(el)) {
|
||||
escaped_id += "-selectized";
|
||||
}
|
||||
var labelNode = $(el).parent().parent()
|
||||
.find('label[for="' + escaped_id + '"]');
|
||||
var labelHTML = "<label for='" + escaped_id + "'></label>";
|
||||
updateLabel(data.label, labelNode, labelHTML, el);
|
||||
updateLabel(data.label, this._getLabelNode(el));
|
||||
|
||||
$(el).trigger('change');
|
||||
},
|
||||
@@ -151,6 +144,13 @@ $.extend(selectInputBinding, {
|
||||
initialize: function(el) {
|
||||
this._selectize(el);
|
||||
},
|
||||
_getLabelNode: function(el) {
|
||||
let escaped_id = $escape(el.id);
|
||||
if (this._is_selectize(el)) {
|
||||
escaped_id += "-selectized";
|
||||
}
|
||||
return $(el).parent().parent().find('label[for="' + escaped_id + '"]');
|
||||
},
|
||||
// Return true if it's a selectize input, false if it's a regular select input.
|
||||
_is_selectize: function(el) {
|
||||
var config = $(el).parent().find('script[data-for="' + $escape(el.id) + '"]');
|
||||
|
||||
Reference in New Issue
Block a user