Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

select2 dropdown selected value doesn't get updated with the updated model #110

@sanathko

Description

@sanathko

I use the latest select2 api (select2-3.4.5) and my html for select 2 looks like this.

         <select ui-select2 id="select2-test" ng-model="mymodel.myTitle">
            <option value="">Title</option>
            <option ng-repeat="title in nameList" value="{{title.key}}">{{title.name}}</option>
        </select>

I am performing a save call in my controller which saves the model and reloads the saved model back. This is done inside the following block.

         $timeout(function(){
            //if(!$scope.$$phase){
                $scope.$apply(function(){
                    //update the model
                    //update code
                })
            //};
        }, 50);

all my text fields gets loaded with the updated data and when I printout {{mymodel}}, I can see the updated model.
I performed save and update call inside $scope.$apply with the intention of updating the dom elements.

after the update when I expand the dropdown (select2), I can see the correctly updated value selected inside the select options.

       <option XXXX selected="selected">MYSELECTED</option>

but select2-container which has

        <span class="select2-chosen">OLD</span> has the old value hence it is shown as the selected value.

Is this an issue with select 2 or am I missing anything?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions