Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dropdown] Add possibility to add header items during js initialization #43

Merged
merged 1 commit into from Jul 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/definitions/modules/dropdown.js
Expand Up @@ -3789,7 +3789,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 @@ -3887,17 +3888,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