diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 97cbbd840..805d06f8a 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/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 }); @@ -910,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) { @@ -1078,7 +1101,22 @@ $.fn.dropdown = function(parameters) { select: { mutation: function(mutations) { module.debug('