PlastronJS icon indicating copy to clipboard operation
PlastronJS copied to clipboard

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

Open casio opened this issue 13 years ago • 1 comments

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.

casio avatar Aug 17 '12 10:08 casio

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?

rhysbrettbowen avatar Aug 17 '12 15:08 rhysbrettbowen