Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Distinguish between toJSON for template rendering and toJSON for saving to server #424

Closed
honi opened this Issue · 2 comments

3 participants

@honi

My REST API needs related resources sent as a string with the related resource uri.
So I configured includeInJSON == Backbone.Model.prototype.idAttribute

But now when I render a template for this model, I can no longer access any of the related model's attributes, because when calling toJSON, only the resource uri is serialized.

Did anybody have this problem? What did you do to work around this issue?

@philfreo
Collaborator

Backbone has recently clarified that the mean purpose of toJSON is for server serialization. You have other options when it comes to template rendering.

But see #161 and #183 for a related proposal

@PaulUithol
Owner

Closing as dup of #183. In general, it's better to just pass the model itself into the template, and use the get accessors`.

@PaulUithol PaulUithol closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.