diff --git a/definitions/collections/menu.less b/definitions/collections/menu.less index 84f9127..defaad5 100644 --- a/definitions/collections/menu.less +++ b/definitions/collections/menu.less @@ -211,7 +211,6 @@ /* Menu */ .ui.menu .dropdown.item .menu { - left: 0px; min-width: ~"calc(100% - 1px)"; border-radius: 0em 0em @dropdownMenuBorderRadius @dropdownMenuBorderRadius; background: @dropdownBackground; diff --git a/definitions/modules/dropdown.js b/definitions/modules/dropdown.js index 25ee5f3..805d06f 100644 --- a/definitions/modules/dropdown.js +++ b/definitions/modules/dropdown.js @@ -97,7 +97,13 @@ $.fn.dropdown = function(parameters) { module.setup.reference(); } else { + module.setup.layout(); + + if(settings.values) { + module.change.values(settings.values); + } + module.refreshData(); module.save.defaults(); @@ -162,7 +168,7 @@ $.fn.dropdown = function(parameters) { observe: { select: function() { if(module.has.input()) { - selectObserver.observe($input[0], { + selectObserver.observe($module[0], { childList : true, subtree : true }); @@ -383,19 +389,16 @@ $.fn.dropdown = function(parameters) { reference: function() { module.debug('Dropdown behavior was called on select, replacing with closest dropdown'); // replace module reference - $module = $module.parent(selector.dropdown); + $module = $module.parent(selector.dropdown); + instance = $module.data(moduleNamespace); + element = $module.get(0); module.refresh(); module.setup.returnedObject(); - // invoke method in context of current instance - if(methodInvoked) { - instance = module; - module.invoke(query); - } }, returnedObject: function() { var $firstModules = $allModules.slice(0, elementIndex), - $lastModules = $allModules.slice(elementIndex + 1) + $lastModules = $allModules.slice(elementIndex + 1) ; // adjust all modules to use correct reference $allModules = $firstModules.add($module).add($lastModules); @@ -913,6 +916,23 @@ $.fn.dropdown = function(parameters) { } }, + change: { + values: function(values) { + if(!settings.allowAdditions) { + module.clear(); + } + module.debug('Creating dropdown with specified values', values); + module.setup.menu({values: values}); + $.each(values, function(index, item) { + if(item.selected == true) { + module.debug('Setting initial selection to', item.value); + module.set.selected(item.value); + return true; + } + }); + } + }, + event: { change: function() { if(!internalChange) { @@ -1081,7 +1101,22 @@ $.fn.dropdown = function(parameters) { select: { mutation: function(mutations) { module.debug('