javascript - Rendr how to pass model to subview in RendrJS isomorphic framework -
assume i'm building blog home page renders list of blog posts. question how pass model each child post view?
i have index.hbs iterating through collection
{{#foreach models}} {{view "post_view" model=value model_name="story"}} {{/foreach}}
i have post_view.js
var baseview = require('./base'); module.exports = baseview.extend({ classname: 'post_view', initialize: function() { console.log(this.model); //undefined console.log(this.options.model); //undefined on client, logs model attributes on server } }); module.exports.id = 'post_view';
but appears model isn't set inside post_view.js. if {{json value}}
inside {{foreach}}
loop can see jsonified output printed. need pass model, need manually construct inside view? thanks!
i don't have reputation comment, isn't answer.
when subview initialized model
isn't there yet. it'll there postrender()
, should there gettemplatedata()
. don't remember exact issue {{view}}
plugin caused race condition, i've seen before. wormhole somewhere around here: https://github.com/rendrjs/rendr/blob/master/shared/base/view.js#l438 , works on server not on client.
Comments
Post a Comment