javascript - How render a route relevant subheader with meteor blaze? -


the end result of of go on subheader not rendering on screen want to.

currently there mongo collection subheader category field , texth field.

subheader = new mongo.collection('subheader');  meteor.methods({   subheaderinsert: function(subheaderidattributes) {   check(string);   check(subheaderidattributes, {     texth: string,     category: string   });   var subheaderid = _.extend(postattributes, {     submitted: new date()   });   var subheaderid = subheaderid.insert(subheader);     return {     _id: subheaderid   }; } }); 

there route subscribes subheader , other page data.

router.route('/', {   name: 'home',     controller: missionstatementpostcontroller,     waiton:function () {   return meteor.subscribe('subheader', 'home');   } }); 

the publish function appears work fine.

meteor.publish('subheader', function(cat) {   return subheader.find({category: cat}); }); 

the correct doc mongodb collection reaching client. can seen by

subheader.findone(); output object {_id: "npo5cwqgjyy6i9rtx", texth: "ex text", category: "home"} 

the problem starts here

the template loaded controller in case missionstatementpostcontroller postlist

<template name="postslist">     <div class="posts page">           {{> subheader}}     <div class="wrapper">       {{#each posts}}         {{> postitem}}       {{/each}}     </div>      {{#if nextpath}}       <a class="load-more" href="{{nextpath}}">load more</a>     {{else}}       {{#unless ready}}         {{> spinner}}       {{/unless}}     {{/if}}   </div> </template> 

here subheader template

<template name="subheader">     <div class="container">         <p>{{{texth}}}</p>     </div> </template> 

so did mess-up?

thanks

you must create template helper subheader template. return texth field, helper this.

template.subheader.helpers({   texth: function() {     var sh = subheader.findone();     return sh && sh.texth;   } }); 

you can return whole document , use #with helper inside template.

template.subheader.helpers({   subh: function() {     return subheader.findone();   } });  <template name="subheader">     {{#with subh}}     <div class="container">         <p>{{{texth}}}</p>     </div>     {{/with}} </template> 

you can find more info template helpers on meteor docs.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -