From 58b404696a711d2abab8abae651032f7e1990770 Mon Sep 17 00:00:00 2001 From: Davi Alexandre Date: Thu, 9 Jul 2015 18:59:56 -0300 Subject: [PATCH] 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. --- src/definitions/modules/dropdown.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 51fe25252..81c4ea2a4 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -2090,6 +2090,12 @@ $.fn.dropdown = function(parameters) { 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); $input .val(value)