-
Notifications
You must be signed in to change notification settings - Fork 422
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
can/map/define default behaviors with "*" #1373
Comments
+1 |
I like it. +1 |
This wil be probably usefull. |
Word. I think I'll quick throw something together, add some tests, and make some documentation modifications. 👍 |
…reaks with YUI, will figure out why later.
Currently sitting on a solution, but the tests are now failing in YUI - though I can't be exactly sure why. Will have to take a look later. |
@daffl @imjoshdean what would it take to get this in for can.List as well? |
Is |
@whitecolor It will affect all attributes - but it will have the same minimal footprint that define has already. |
Is this supposed to work? In master? |
Yes. But @imjoshdean still needs to add documentation (#1449) |
http://jsfiddle.net/xKc3H/367/ var Model = can.Model.extend({
define: {
name: {
value: 'Alex'
},
'*': {
serialize: false
}
}
})
var model = new Model({age: 10, name: 'John'})
console.log(model.serialize()) Why result is |
@whitecolor Your use case is the entire reason why I wrote the define default behavior to begin with. I'll have a fix in before end of weekend. |
@whitecolor - Check the provided diff. I added your test with a minor tweak to the define tests. Thanks for catching this, because as I said...your use case was the whole purpose to me making this feature. I want to tie AppState to can.route, but I don't want EVERYTHING put in AppState to be serialized. |
...aside from the linting erros. :S |
Fix issue found in #1373 with not properly using defaults
It would be really nice if we could create default behaviors for map attributes. For example, I have an AppState object tied to my can.route; however, not every attribute I want to throw on the AppState should be serialized and put into the route. Right now I have to define every attribute I want to put in my AppState with:
What would be nicer to have would be to have a catch all definition for attribute behaviors, say,
"*"
, that would provide a set of behaviors for all attributes unless otherwise defined. So for example:serializeOne
andserializeTwo
would be typed as strings and be serializable; all other attributes on the Map wouldn't be serialized but will be also typed as strings.The text was updated successfully, but these errors were encountered: