ui-select2 icon indicating copy to clipboard operation
ui-select2 copied to clipboard

ui select 2 selected value doesnt change

Open SalmanZafar214 opened this issue 12 years ago • 3 comments

i m using ui.select2 for dropdowns

Scenario i have an ajax call that return drop down values

document.dropDownDocStatuses = [
            { key: 0, value: 'All active (' + response.totalDocuments + ')' },
            { key: 1, value: 'Draft (' + response.draft + ')' }            
        ];

in html i have

<select ui-select2 class="form-control font-12px input-style3 " 
ng-model="document.dropDownDocStatus"        
ng-change="document.filterDocuments()">
<option ng-repeat="documents in document.dropDownDocStatuses"  value="{{documents.key}}">({{documents.value}})</option>  </select>

user have selected value enter image description here

Issue now when i update any value of dropdown using

  _document.dropDownDocStatuses[_document.dropDownDocStatus].value++;
                _document.dropDownDocStatuses[1].value++;

valuge gets updated but it doesnt change selected value text whereas if i click on dropdown i get changed value in dropdown enter image description here

can someone guide me how can i fix the issue, any help will be appreciated http://stackoverflow.com/questions/22867081/ui-select-2-selected-value-doesnt-change-angularjs

please some one can help me ?

SalmanZafar214 avatar Apr 05 '14 11:04 SalmanZafar214

I'm experiencing a similar problem. If I update the model programmatically via a controller or a different input control pointing to the same model, the selected item within select2 does not change. However, clicking on the dropdown reveals that the correct item is highlighted.

colinvella avatar Jul 15 '14 13:07 colinvella

I am having exactly the same issue, the only way to get it working is to call this line from the controller to update the UI, it works but doesn't look pretty, any ideas why this is happening please? $('#dropDown').select2('val', $scope.modelValue);

azeyad avatar Aug 02 '14 02:08 azeyad

I found a workaround for this. Check my post

colinvella avatar Aug 02 '14 10:08 colinvella