From ce0740358050024d9576fa56e1c5bceaf0a074fb Mon Sep 17 00:00:00 2001 From: jlukic Date: Tue, 23 Dec 2014 11:41:37 -0500 Subject: [PATCH] Adds #1503, adds sortSelect option, fixes select to preserve original value order by default --- src/definitions/modules/dropdown.js | 37 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 74ebfe5bb..0ceb765a7 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -771,9 +771,11 @@ $.fn.dropdown = function(parameters) { }, selectValues: function() { var - select = { - values : {} - } + select = {} + ; + select.values = (settings.sortSelect) + ? {} // properties will be sorted in object when re-accessed + : [] // properties will keep original order in array ; $module .find('option') @@ -788,11 +790,27 @@ $.fn.dropdown = function(parameters) { select.placeholder = name; } else { - select.values[value] = name; + if(settings.sortSelect) { + select.values[value] = { + name : name, + value : value + }; + } + else { + select.values.push({ + name: name, + value: value + }); + } } }) ; - module.debug('Retrieved values from select', select); + if(settings.sortSelect) { + module.debug('Retrieved and sorted values from select', select); + } + else { + module.debug('Retreived values from select', select); + } return select; }, activeItem: function() { @@ -1476,6 +1494,7 @@ $.fn.dropdown.settings = { allowTab : true, fullTextSearch : false, preserveHTML : true, + sortSelect : false, delay : { hide : 300, @@ -1545,8 +1564,8 @@ $.fn.dropdown.settings.templates = { values = select.values || {}, html = '' ; - $.each(select.values, function(value, name) { - html += '
' + name + '
'; + $.each(select.values, function(index, option) { + html += '
' + option.name + '
'; }); return html; }, @@ -1564,8 +1583,8 @@ $.fn.dropdown.settings.templates = { html += '
'; } html += ''; return html;