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

Array is skipped on serialize #393

Closed
rxaviers opened this issue May 24, 2013 · 3 comments
Closed

Array is skipped on serialize #393

rxaviers opened this issue May 24, 2013 · 3 comments
Milestone

Comments

@rxaviers
Copy link

Demo: http://jsfiddle.net/rLDHc/1

Should it be accomplished in a different way? I noticed that when an Array is set by .attr(), it is wrapped into another Object with its own .serialize() method. This method is called instead of its type Class.serialize.

@ghost ghost assigned fara82 May 26, 2013
@ghost ghost assigned daffl Jul 18, 2013
@codr
Copy link

codr commented Jul 25, 2013

You are right, the array is converted into an can.Observe.List here and here. It's own serialize takes precedence.

One solution is to build the can.Observe.List yourself and give it a serialize function.
Demo: http://jsfiddle.net/rLDHc/5/

@rxaviers
Copy link
Author

Yeap, that's awkward. Thanks for the workaround though.

Considering an Array could be part of a model (an attribute), it should behave just like any other datatypes.

@ghost ghost assigned imjoshdean Sep 27, 2013
@imjoshdean
Copy link
Contributor

As @codr mentioned, can.Observe's serialize takes precedence, because this is the root of how can.Observes work. That said, this is being investigated in #274.

In the mean time, @codr's solution works. And I am going to close so we have only one issue open for the same thing.

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

No branches or pull requests

5 participants