Browse Source

Properly set the dropdown value when dealing with remote loaded choices

This problem happens only when we have a dropdown created from a select
that loads remote content. In this scenario, we don't know in advance
which choices will be available, so we start with a select without any
options. When an choice is selected, module.set.value will try to set
the select value, but it will fail, since there's no options.

To fix this, module.set.value will add a new option to the select, before
setting the value. This will be done only if the dropdown input is a select
and if we are dealing with remote loaded content.
pull/2573/head
Davi Alexandre 9 years ago
parent
commit
58b404696a
1 changed files with 6 additions and 0 deletions
  1. 6
      src/definitions/modules/dropdown.js

6
src/definitions/modules/dropdown.js

@ -2090,6 +2090,12 @@ $.fn.dropdown = function(parameters) {
return; return;
} }
} }
if($input.is('select') && settings.apiSettings) {
module.debug('Adding an option to the select before setting the value', value);
module.add.optionValue(value);
}
module.debug('Updating input value', value, currentValue); module.debug('Updating input value', value, currentValue);
$input $input
.val(value) .val(value)

Loading…
Cancel
Save