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

Feature request: Pass array to .unset() #45

Closed
jrmyio opened this issue Aug 12, 2014 · 7 comments
Closed

Feature request: Pass array to .unset() #45

jrmyio opened this issue Aug 12, 2014 · 7 comments

Comments

@jrmyio
Copy link

jrmyio commented Aug 12, 2014

It would be handy to be able to parse an array of keys to unset when calling unset().
this.model.unset(["prop1", "prop2"]);

Also, the docs on http://ampersandjs.com/docs#ampersand-state-set when using "unset" as option do not make clear what it actually does.

@wraithgar
Copy link
Contributor

the unset parameter probably isn't worth documenting. It's in there because it was inherited from the backbone source (that's how it does .unset()). unset takes all the same parameters and should be how people unset things imo

@wraithgar
Copy link
Contributor

set('foo', {unset: true}) would also bypass the defaults.

@wraithgar
Copy link
Contributor

This was discussed some in the irc channel this week and some people are wondering if we even want .unset(). What is your use case for that?

@jrmyio
Copy link
Author

jrmyio commented Aug 16, 2014

I wanted to set half the model to its default settings without me actually writing these default values as these are already part of the model description. Is there a different way with "set" to do this?

@wraithgar
Copy link
Contributor

Ah ok yes the required/default thing seems to be confusing people. If you set required:true and also set a default then that default will be set on model instantiation.

@jdiaz5513
Copy link

Would also like to see unset take an array. I have an app that needs to unset quite a few attributes at once and each change event fired does some kind-of expensive stuff that I'd like to avoid running 20 times.

Willing to submit a PR if nobody else is biting.

wraithgar pushed a commit that referenced this issue Mar 31, 2015
Add ability to unset an array. Closes #45
@latentflip
Copy link
Contributor

Released in 4.5.0

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

No branches or pull requests

5 participants