Browse Source

Add fix for restoring labels

pull/2300/head
jlukic 9 years ago
parent
commit
14014ef4b5
2 changed files with 35 additions and 8 deletions
  1. 42
      src/definitions/modules/dropdown.js
  2. 1
      src/definitions/modules/dropdown.less

42
src/definitions/modules/dropdown.js

@ -86,7 +86,12 @@ $.fn.dropdown = function(parameters) {
module.save.defaults(); module.save.defaults();
if(!settings.apiSettings) {
if(settings.apiSettings) {
if( module.is.multiple() ) {
module.restore.labels();
}
}
else {
module.set.selected(); module.set.selected();
} }
@ -230,9 +235,9 @@ $.fn.dropdown = function(parameters) {
api: function() { api: function() {
var var
apiSettings = { apiSettings = {
debug : settings.debug,
cache : true,
on : false
debug : settings.debug,
cache : 'local',
on : false
} }
; ;
module.verbose('First request, initializing API'); module.verbose('First request, initializing API');
@ -558,9 +563,14 @@ $.fn.dropdown = function(parameters) {
return; return;
} }
if(settings.apiSettings) { if(settings.apiSettings) {
module.queryRemote(searchTerm, function() {
afterFiltered();
});
if( module.can.useAPI() ) {
module.queryRemote(searchTerm, function() {
afterFiltered();
});
}
else {
module.error(error.noAPI);
}
} }
else { else {
module.filterItems(searchTerm); module.filterItems(searchTerm);
@ -577,9 +587,11 @@ $.fn.dropdown = function(parameters) {
}, },
onError: function() { onError: function() {
module.add.message(message.serverError); module.add.message(message.serverError);
callback();
}, },
onFailure: function() { onFailure: function() {
module.add.message(message.serverError); module.add.message(message.serverError);
callback();
}, },
onSuccess : function(response) { onSuccess : function(response) {
module.remove.message(); module.remove.message();
@ -596,6 +608,7 @@ $.fn.dropdown = function(parameters) {
apiSettings = $.extend(true, {}, apiSettings, settings.apiSettings); apiSettings = $.extend(true, {}, apiSettings, settings.apiSettings);
$module $module
.api('setting', apiSettings) .api('setting', apiSettings)
.api('abort')
.api('query') .api('query')
; ;
}, },
@ -1593,6 +1606,17 @@ $.fn.dropdown = function(parameters) {
module.remove.selectedItem(); module.remove.selectedItem();
} }
} }
},
labels: function() {
var
values = module.get.values()
;
if(values) {
$.each(values, function(index, value) {
module.add.label(value, value);
});
}
module.debug('Recreating all labels');
} }
}, },
@ -2399,6 +2423,9 @@ $.fn.dropdown = function(parameters) {
}, },
show: function() { show: function() {
return !$module.hasClass(className.disabled) && $item.length > 0; return !$module.hasClass(className.disabled) && $item.length > 0;
},
useAPI: function() {
return $.fn.api !== undefined;
} }
}, },
@ -2794,6 +2821,7 @@ $.fn.dropdown.settings = {
alreadySetup : 'Once a select has been initialized behaviors must be called on the created ui dropdown', alreadySetup : 'Once a select has been initialized behaviors must be called on the created ui dropdown',
labels : 'Allowing user additions currently requires the use of labels.', labels : 'Allowing user additions currently requires the use of labels.',
method : 'The method you called is not defined.', method : 'The method you called is not defined.',
noAPI : 'The API module is required to load resources remotely',
noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>' noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>'
}, },

1
src/definitions/modules/dropdown.less

@ -33,7 +33,6 @@
transition: @transition; transition: @transition;
} }
/******************************* /*******************************
Content Content
*******************************/ *******************************/

Loading…
Cancel
Save