Array is skipped on serialize #393

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

Comments

Projects
None yet
5 participants
@rxaviers

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

This comment has been minimized.

Show comment
Hide comment
@codr

codr 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/

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

This comment has been minimized.

Show comment
Hide comment
@rxaviers

rxaviers Jul 26, 2013

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.

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

This comment has been minimized.

Show comment
Hide comment
@imjoshdean

imjoshdean Sep 30, 2013

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.

Contributor

imjoshdean commented Sep 30, 2013

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.

@imjoshdean imjoshdean closed this Sep 30, 2013

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