Skip to content

Commit

Permalink
Merge pull request #43 from prudho/enh-6420
Browse files Browse the repository at this point in the history
[Dropdown] Add possibility to add header items during js initialization
  • Loading branch information
Sean committed Jul 4, 2018
2 parents 8eba32c + 582ea18 commit 83602a8
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/definitions/modules/dropdown.js
Expand Up @@ -3853,7 +3853,8 @@ $.fn.dropdown.settings = {
disabled : 'disabled', // whether value should be disabled
name : 'name', // displayed dropdown text
value : 'value', // actual dropdown value
text : 'text' // displayed text when selected
text : 'text', // displayed text when selected
type : 'type' // type of dropdown element
},

keys : {
Expand Down Expand Up @@ -3952,17 +3953,29 @@ $.fn.dropdown.settings.templates = {
html = ''
;
$.each(values, function(index, option) {
var
maybeText = (option[fields.text])
? 'data-text="' + option[fields.text] + '"'
: '',
maybeDisabled = (option[fields.disabled])
? 'disabled '
: ''
var
itemType = (option[fields.type])
? option[fields.type]
: 'item'
;
html += '<div class="'+ maybeDisabled +'item" data-value="' + option[fields.value] + '"' + maybeText + '>';
html += option[fields.name];
html += '</div>';

if( itemType === 'item' ) {
var
maybeText = (option[fields.text])
? 'data-text="' + option[fields.text] + '"'
: '',
maybeDisabled = (option[fields.disabled])
? 'disabled '
: ''
;
html += '<div class="'+ maybeDisabled +'item" data-value="' + option[fields.value] + '"' + maybeText + '>';
html += option[fields.name];
html += '</div>';
} else if (itemType === 'header') {
html += '<div class="header">';
html += option[fields.name];
html += '</div>';
}
});
return html;
},
Expand Down

0 comments on commit 83602a8

Please sign in to comment.