Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Commit

Permalink
Rename 'isDirty' to 'hasDirtyAttributes'
Browse files Browse the repository at this point in the history
Ember Data deprecated `Model.isDirty` in favor of `Model.hasDirtyAttributes`.
(emberjs/data#3351)
  • Loading branch information
mikzar authored and locks committed Nov 7, 2015
1 parent 615c017 commit 73c5f13
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions source/models/creating-updating-and-deleting-records.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,33 +95,33 @@ store.findRecord('post', 1).then(function(post) {
```

You can tell if a record has outstanding changes that have not yet been
saved by checking its `isDirty` property. You can also see what parts of
saved by checking its `hasDirtyAttributes` property. You can also see what parts of
the record were changed and what the original value was using the
`changedAttributes` function. `changedAttributes` returns an object,
whose keys are the changed properties and values are an array of values
`[oldValue, newValue]`.

```js
person.get('isAdmin'); //=> false
person.get('isDirty'); //=> false
person.get('isAdmin'); //=> false
person.get('hasDirtyAttributes'); //=> false
person.set('isAdmin', true);
person.get('isDirty'); //=> true
person.changedAttributes(); //=> { isAdmin: [false, true] }
person.get('hasDirtyAttributes'); //=> true
person.changedAttributes(); //=> { isAdmin: [false, true] }
```

At this point, you can either persist your changes via `save()` or you
can rollback your changes. Calling `rollbackAttributes()` reverts all the
`changedAttributes` to their original value.

```js
person.get('isDirty'); //=> true
person.changedAttributes(); //=> { isAdmin: [false, true] }
person.get('hasDirtyAttributes'); //=> true
person.changedAttributes(); //=> { isAdmin: [false, true] }

person.rollbackAttributes();

person.get('isDirty'); //=> false
person.get('isAdmin'); //=> false
person.changedAttributes(); //=> {}
person.get('hasDirtyAttributes'); //=> false
person.get('isAdmin'); //=> false
person.changedAttributes(); //=> {}
```

## Promises
Expand Down

0 comments on commit 73c5f13

Please sign in to comment.