Skip to content

Commit cfc5a74

Browse files
authored
feat(dropdown): support submenu values
When a dropdown was initialized by providing its values via settings parameter, it was not possible to define a submenu structure, which will also simplify such tasks when working with remote data. This was only possible by using existing DOM structure before. This PR now allows for a value type menu, left menu, right menu.
1 parent ef3d810 commit cfc5a74

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/definitions/modules/dropdown.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4157,6 +4157,7 @@ $.fn.dropdown.settings = {
41574157
search : 'search',
41584158
selected : 'selected',
41594159
selection : 'selection',
4160+
text : 'text',
41604161
upward : 'upward',
41614162
leftward : 'left',
41624163
visible : 'visible',
@@ -4232,10 +4233,11 @@ $.fn.dropdown.settings.templates = {
42324233
var
42334234
itemType = (option[fields.type])
42344235
? option[fields.type]
4235-
: 'item'
4236+
: 'item',
4237+
isMenu = itemType.indexOf('menu') !== -1
42364238
;
42374239

4238-
if( itemType === 'item' ) {
4240+
if( itemType === 'item' || isMenu) {
42394241
var
42404242
maybeText = (option[fields.text])
42414243
? ' data-text="' + deQuote(option[fields.text],true) + '"'
@@ -4245,13 +4247,25 @@ $.fn.dropdown.settings.templates = {
42454247
: ''
42464248
;
42474249
html += '<div class="'+ maybeDisabled + (option[fields.class] ? deQuote(option[fields.class]) : className.item)+'" data-value="' + deQuote(option[fields.value],true) + '"' + maybeText + '>';
4250+
if (isMenu) {
4251+
html += '<i class="'+ (itemType.indexOf('left') !== -1 ? 'left' : '') + ' dropdown icon"></i>';
4252+
}
42484253
if(option[fields.image]) {
42494254
html += '<img class="'+(option[fields.imageClass] ? deQuote(option[fields.imageClass]) : className.image)+'" src="' + deQuote(option[fields.image]) + '">';
42504255
}
42514256
if(option[fields.icon]) {
42524257
html += '<i class="'+deQuote(option[fields.icon])+' '+(option[fields.iconClass] ? deQuote(option[fields.iconClass]) : className.icon)+'"></i>';
42534258
}
4259+
if (isMenu) {
4260+
html += '<span class="' + className.text + '">';
4261+
}
42544262
html += escape(option[fields.name] || '', preserveHTML);
4263+
if (isMenu) {
4264+
html += '</span>';
4265+
html += '<div class="' + itemType + '">';
4266+
html += $.fn.dropdown.settings.templates.menu(option, fields, preserveHTML, className);
4267+
html += '</div>';
4268+
}
42554269
html += '</div>';
42564270
} else if (itemType === 'header') {
42574271
var groupName = escape(option[fields.name] || '', preserveHTML),

0 commit comments

Comments
 (0)