Skip to content

Commit

Permalink
#2645 adds fields array to dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Aug 18, 2015
1 parent 326e1df commit ceb489e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- **Checkbox** - Added 4 new callbacks `beforeChecked`, `beforeUnchecked`, `beforeDeterminate`, `beforeIndeterminate`. You can now cancel a state change by returning false from these callbacks.
- **Divider** - Vertical divider can now be used multiple times in a single column row (not just 50/50 split). #2808
- **Dropdown** - Dropdown will now automatically update selected values when hidden input value changes (so long as `change` event is triggered) #2626
- **Dropdown** - Dropdown using remote data, can now customize the property names returned by api call using `fields` (similar to search).
- **Form Validation** - Added credit card validation, supports array of card types, and international cards including non luhn cards like China UnionPay #2729
- **Form Validation** - Updated appearance of form validation prompts to use a more lightweight style. Added variables for controlling error validation prompt styles in `form.variables`
- **Grid** - Added new responsive [`reversed`](http://www.semantic-ui.com/collections/grid.html#responsive-order) variations for reversing column order, these are also compatible with other grid types like `divided` and `celled` by device #2685
Expand Down
17 changes: 12 additions & 5 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ $.fn.dropdown = function(parameters) {

className = settings.className,
message = settings.message,
fields = settings.fields,
metadata = settings.metadata,
namespace = settings.namespace,
regExp = settings.regExp,
Expand Down Expand Up @@ -328,7 +329,7 @@ $.fn.dropdown = function(parameters) {
module.refresh();
},
menu: function(values) {
$menu.html( templates.menu( values ));
$menu.html( templates.menu(values, fields));
$item = $menu.find(selector.item);
},
reference: function() {
Expand Down Expand Up @@ -2544,7 +2545,6 @@ $.fn.dropdown = function(parameters) {
;
if(module.is.multiple()) {
if(settings.useLabels) {
console.log(selectedValue);
module.remove.value(selectedValue, selectedText, $selected);
module.remove.label(selectedValue);
}
Expand Down Expand Up @@ -3293,6 +3293,13 @@ $.fn.dropdown.settings = {
value : 'value'
},

// property names for remote query
fields: {
values : 'values',
name : 'name',
value : 'value'
},

selector : {
addition : '.addition',
dropdown : '.ui.dropdown',
Expand Down Expand Up @@ -3363,13 +3370,13 @@ $.fn.dropdown.settings.templates = {
},

// generates just menu from select
menu: function(response) {
menu: function(response, fields) {
var
values = response.values || {},
html = ''
;
$.each(response.values, function(index, option) {
html += '<div class="item" data-value="' + option.value + '">' + option.name + '</div>';
$.each(response[fields.values], function(index, option) {
html += '<div class="item" data-value="' + option[fields.value] + '">' + option[fields.name] + '</div>';
});
return html;
},
Expand Down

0 comments on commit ceb489e

Please sign in to comment.