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

Can be disabled or readonly to begin with. #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
elm.trigger('change');
}
});
}
}
} else {
if (angular.isObject(controller.$viewValue)) {
elm.select2('data', controller.$viewValue);
Expand Down Expand Up @@ -164,7 +164,7 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
// Set the view and model value and update the angular template manually for the ajax/multiple select2.
elm.bind("change", function (e) {
e.stopImmediatePropagation();

if (scope.$$phase || scope.$root.$$phase) {
return;
}
Expand Down Expand Up @@ -195,14 +195,6 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
elm.select2("destroy");
});

attrs.$observe('disabled', function (value) {
elm.select2('enable', !value);
});

attrs.$observe('readonly', function (value) {
elm.select2('readonly', !!value);
});

if (attrs.ngMultiple) {
scope.$watch(attrs.ngMultiple, function(newVal) {
attrs.$set('multiple', !!newVal);
Expand Down Expand Up @@ -231,6 +223,14 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
}
elm.prev().toggleClass('ng-pristine', controller.$pristine);
}

attrs.$observe('disabled', function (value) {
elm.select2('enable', !value);
});

attrs.$observe('readonly', function (value) {
elm.select2('readonly', !!value);
});
});
};
}
Expand Down