icereval/backbone-documentmodel

toJSON of arrays for template rendering

Opened this issue · 0 comments

Hi,

I see how arrays are turned into Collections containing Models with "pseudoIdAttributes", which i understand is necessary so that the data can we reconverted to an array on it's way back up the pipe. The issue is that when you pass one of these special models with pseudoIdAttributes to a itemView in Backbone, the template receives a string instead of an object. Marionette hangs templateHelpers on this object, so basically using DocumentModel kills Marionette's templateHelpers.

I can't imagine this is something you'd be able to solve since you can't know in which context toJSON is being called. I'm having to work around it by modifying Marionette's serializeData method on itemViews to convert any strings into objects with a named key:value pair. Just an FYI, unless you have any ideas?