Dziamid
Dziamid

Reputation: 11571

Delete created uncommitted record?

I can not figure out how to delete a model created by App.store.createRecord(). Have a look at this fiddle: http://jsfiddle.net/Adw4F/2/ You can delete record loaded from fixtures (or rest adapter), but not created.

Upvotes: 5

Views: 1564

Answers (3)

Steven Soroka
Steven Soroka

Reputation: 19902

You should be able to do:

record.deleteRecord({})

Or roll the transaction back.

Upvotes: 0

barcrab
barcrab

Reputation: 199

If you haven't commit'ed the record, all you need to do is rollback the transaction.

Ember uses a default transaction if one wasn't specified. For example:

record.get('transaction').rollback();

This will transition the record to the deleted state.

Upvotes: 2

Mike Aski
Mike Aski

Reputation: 9236

Using the very last version of ember-data, and adding a few (ugly|crappy|clumsy) things, I got it working. Obviously not ideal, but working...

See http://jsfiddle.net/MikeAski/Adw4F/32/

Upvotes: 1

Related Questions