Browse Source

#2403 [Dropdown] Merge and organize metadata refresh

pull/2416/head
jlukic 9 years ago
parent
commit
913194ca6b
1 changed files with 17 additions and 14 deletions
  1. 31
      src/definitions/modules/dropdown.js

31
src/definitions/modules/dropdown.js

@ -87,6 +87,8 @@ $.fn.dropdown = function(parameters) {
} }
else { else {
module.setup.layout(); module.setup.layout();
module.refreshData();
module.save.defaults(); module.save.defaults();
module.restore.selected(); module.restore.selected();
@ -101,7 +103,6 @@ $.fn.dropdown = function(parameters) {
module.instantiate(); module.instantiate();
} }
module.refreshData();
}, },
instantiate: function() { instantiate: function() {
@ -345,6 +346,11 @@ $.fn.dropdown = function(parameters) {
}, },
refresh: function() { refresh: function() {
module.refreshSelectors();
module.refreshData();
},
refreshSelectors: function() {
module.verbose('Refreshing selector cache'); module.verbose('Refreshing selector cache');
$text = $module.find(selector.text); $text = $module.find(selector.text);
$search = $module.find(selector.search); $search = $module.find(selector.search);
@ -356,22 +362,19 @@ $.fn.dropdown = function(parameters) {
; ;
$menu = $module.children(selector.menu); $menu = $module.children(selector.menu);
$item = $menu.find(selector.item); $item = $menu.find(selector.item);
module.refreshData();
}, },
refreshData: function() { 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)
;
}, },

Loading…
Cancel
Save