You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
If I have an model A, which contains object b, then serialize object a, I would it expect b.serialize() to be called as a part of a.serialize(). This is currently not the case.
I'm making a CompositeModel which essentially works as a group of models (for convenience and is itself not synced) and want it's models to decide of they serialize themselves. Here is my workaround there:
utils=require'lib/utils'Model=require'models/base/model'serializeAttributes= (model, attributes, modelStack) -># Create a delegator object.delegator=utils.beget attributes
# Map model/collection to their attributes. Create a property# on the delegator that shadows the original attribute.for key, value of attributes
delegator[key] =utils.serialize(value)
# Return the delegator.return delegator
module.exports=classCompositeModelextendsModelserialize:->serializeAttributesthis, @getAttributes()
fetch:->promises= []
attributes=@getAttributes()
for key, value of attributes
iftypeofvalue.fetchis'function'promises.pushvalue.fetch()
return$.when.apply($, promises)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
If I have an model
A
, which contains objectb
, then serialize objecta
, I would it expectb.serialize()
to be called as a part ofa.serialize()
. This is currently not the case.I'm making a
CompositeModel
which essentially works as a group of models (for convenience and is itself not synced) and want it's models to decide of they serialize themselves. Here is my workaround there:The text was updated successfully, but these errors were encountered: