Skip to content

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 committed Sep 25, 2015
1 parent cd046be commit f8907be
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 f8907be

Please sign in to comment.