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

mvc.Model: add .toJsObject() to retrieve all attrs, including schema/meta/format defs #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

casio
Copy link

@casio casio commented Aug 17, 2012

In order to, for example, pass the current model state to a template, it would be nice to have a nicely formatted represenation of all attrs available.

.toJson() currently only returns the fields defined in this.attr_, and the values retrieved dont respect the fields formatters, so I thought adding .toJsObject() might be of help.

@rhysbrettbowen
Copy link
Owner

would it be better to wrap this up in the toJSON() function and pass in true to get back the formatted object.

so object.toJSON(true); will pass back a formatted object? or how about calling it .toFormattedObj() or something similar?

I'm leaning towards the .toFormattedObj as it's more descriptive and the toJSON is used by JSON.stringify which should save the attributes as is rather than the formatted ones.

can you also add in the method to the README?

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

Successfully merging this pull request may close these issues.

2 participants