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

Double Change invoke on ajax provider used

Open Color-Ant opened this issue 11 years ago • 1 comments

Hi, when I use

      $scope.streetSelect2Options = {           
            itemsPerPage: 40,
            minimumResultsForSearch: 0,
            initSelection: angular.noop,
            ajax: {
                quietMillis: 300,
                transport: function (query) {
                    // some service return defer
                    return FiasResource.street().query(query.data)
                        .then(function (data) {
                            query.success(data);
                        });
                },
                data: function (term, page) {
                    var that = this;
                    return _.merge(
                        createSearchParams(),
                        {
                            searchString: term,
                            page: page,
                            itemsPerPage: that.itemsPerPage
                        }
                    );
                },
                results: function (data, page, query) {
                    var that = this;
                    return {
                        more: !_.isEmpty(data) && data.length >= that.itemsPerPage,
                        results: _.map(data, function (street) {
                            return {
                                id: street.guid,
                                text: $scope.name(street, true)
                            };
                        })
                    };
                }
            }
        };

For element in template

           <input type="text" 
                   class="form-control"
                   id='street'
                   name='street'
                   data-placeholder="Выберите улицу"
                   ng-model='searchParameters.streetGuid'
                   ui-select2="streetSelect2Options"
                   ng-change="streetChange()"
                   ng-disabled="!searchParameters.cityGuid"
                    >
            </input>

I have duplicate streetChange() invoke First: right with data.id, as I hope. Second: wrong, with all object { 'id': ..., 'text': ... };

elm.bind("change", function (e) {

and

convertToAngularModel(elm.select2('data')));

not alow what

scope.$watch(tAttrs.ngModel, function(current, old) {

already work

and convertToAngularModel not use standart select2.id function to convert data. But multi_tags useable onli with multiple.

Color-Ant avatar Jun 26 '14 11:06 Color-Ant

I am also having the same problem.

gaprl avatar Sep 15 '14 20:09 gaprl