From 913194ca6b53c89f94b2ceae387b871de88af135 Mon Sep 17 00:00:00 2001 From: jlukic Date: Mon, 15 Jun 2015 11:15:26 -0400 Subject: [PATCH] #2403 [Dropdown] Merge and organize metadata refresh --- src/definitions/modules/dropdown.js | 31 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 0bd9276e2..ba97fab90 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -87,6 +87,8 @@ $.fn.dropdown = function(parameters) { } else { module.setup.layout(); + module.refreshData(); + module.save.defaults(); module.restore.selected(); @@ -101,7 +103,6 @@ $.fn.dropdown = function(parameters) { module.instantiate(); } - module.refreshData(); }, instantiate: function() { @@ -345,6 +346,11 @@ $.fn.dropdown = function(parameters) { }, refresh: function() { + module.refreshSelectors(); + module.refreshData(); + }, + + refreshSelectors: function() { module.verbose('Refreshing selector cache'); $text = $module.find(selector.text); $search = $module.find(selector.search); @@ -356,22 +362,19 @@ $.fn.dropdown = function(parameters) { ; $menu = $module.children(selector.menu); $item = $menu.find(selector.item); - - module.refreshData(); }, refreshData: function() { - $menu - .children() - .each(function() { - $(this).removeData(metadata.text); - $(this).removeData(metadata.value); - }); - - $module.removeData(metadata.defaultText); - $module.removeData(metadata.defaultValue); - $module.removeData(metadata.placeholderText); - + module.verbose('Refreshing cached metadata'); + $item + .removeData(metadata.text) + .removeData(metadata.value) + ; + $module + .removeData(metadata.defaultText) + .removeData(metadata.defaultValue) + .removeData(metadata.placeholderText) + ; },