vendredi 13 novembre 2015

Detect if a newly created model has changed attributes

Say you have a /new route, and the router creates a new instance of your model.

Your model's properties are bound to some input fields on the page.

I want to be able to detect if the new model has changed since it's instantiation.

model.get('hasDirtyAttributes') unfortunately reports true for new instances, because it has not been saved yet.

I thought to try model.get('hasDirtyAttributes') && model.get('dirtyType') === 'updated' but dirtyType is still created until you do the first save.




Aucun commentaire:

Enregistrer un commentaire