Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

#289 - Multiple select to not set form to dirty as soon as it load #509

Merged
merged 2 commits into from
Dec 19, 2014
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1109,8 +1109,13 @@
if (oldValue != newValue)
ngModel.$modelValue = null; //Force scope model value and ngModel value to be out of sync to re-run formatters
});
$select.firstPass = true; // so the form doesn't get dirty as soon as it loads
scope.$watchCollection('$select.selected', function() {
ngModel.$setViewValue(Date.now()); //Set timestamp as a unique string to force changes
if (!$select.firstPass) {
ngModel.$setViewValue(Date.now()); //Set timestamp as a unique string to force changes
} else {
$select.firstPass = false;
}
});
focusser.prop('disabled', true); //Focusser isn't needed if multiple
}else{
Expand Down
10 changes: 5 additions & 5 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ describe('ui-select tests', function() {
beforeEach(function() {
disablePerson({
disableAttr : 'inactive',
disableBool : true,
disableBool : true
});
this.el = createUiSelect({
disabled: 'person.inactive'
Expand Down Expand Up @@ -437,7 +437,7 @@ describe('ui-select tests', function() {
beforeEach(function() {
disablePerson({
disableAttr : 'active',
disableBool : false,
disableBool : false
});
this.el = createUiSelect({
disabled: '!person.active'
Expand Down Expand Up @@ -1123,13 +1123,13 @@ describe('ui-select tests', function() {
expect(el.find('.ui-select-match-item').length).toBe(0);
});

it('should set model as an empty array if ngModel isnt defined', function () {
it('should set model as an empty array if ngModel isnt defined after an item is selected', function () {

// scope.selection.selectedMultiple = [];
var el = createUiSelectMultiple();

expect(scope.selection.selectedMultiple instanceof Array).toBe(false);
clickItem(el, 'Samantha');
expect(scope.selection.selectedMultiple instanceof Array).toBe(true);

});

it('should render initial selected items', function() {
Expand Down