Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove isNew check on store.destroy #133

Merged
merged 1 commit into from Jun 13, 2014

Conversation

renfredxh
Copy link
Contributor

This line that checks model.isNew() causes and error when trying to store Backbone Collections. Collection objects do not have a isNew method so it fails when reaching this point.

The check is unnecessary (it seems it wasn't put in for a specific reason other than to skip the rest of the method if the model hasn't been saved). The official Backbone implementation of sync doesn't have anything like this either.

If you'd rather keep it, we could put in something like if (model.isNew !== undefined && model.isNew()) to ensure it doesn't fail with collections.

Side note: this was hard for me to debug because the block that was calling destroy is incased in a try-catch that was swallowing the useful errors. Might be good to add a console.error(errorMessage) here

@renfredxh renfredxh changed the title Remove isNew check on model.destroy Remove isNew check on store.destroy Jun 12, 2014
jeromegn added a commit that referenced this pull request Jun 13, 2014
@jeromegn jeromegn merged commit 6dce88b into jeromegn:master Jun 13, 2014
@jeromegn
Copy link
Owner

Makes sense. Thanks for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants