ember.js - How to prevent a model from being committed with ember-data? -
i'm using latest rev of ember-data , have typical situation of models need managed ember-data when commit on store sync w/ backend. in 1 particular case have model used clientside (but created ds.model because has relationships other ember-data models in running app).
what can mark on model create sure never looks "dirty" or "new"
i tried doing when object created it's still beingness alter tracked odd reason
app.foo.createrecord({name: 'foo', loaded: true, new: false, dirty: false});
you can add together model it's own transaction.
transaction = this.get('store').transaction(); myobject = transaction.createrecord(app.foo, {name: 'foo', loaded: true, new: false, dirty: false}); transaction.commit(); // or alternatively: myobject.transaction.commit()
a normal store.commit() not impact objects in transaction.
ember creates default transaction in background, gets committed when phone call naked this.get('store').commit();
you can add together existing records transaction going:
foo = app.foo.find(1); transaction = this.get('store').transaction(); transaction.add(foo); foo.set('name', 'bar'); transaction.commit();
if don't want commit transaction , don't want maintain changes made in lying around, can call:
transaction.rollback();
ember.js ember-data
No comments:
Post a Comment