Meteorjs-将数据上下文传递给模板渲染函数? [英] Meteorjs - Passing data context to Template Rendered function?

查看:125
本文介绍了Meteorjs-将数据上下文传递给模板渲染函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有这些数据上下文,并且我想使用JQuery来基于值在标记中设置选定的值.

I have these data context and I want to use JQuery to set the selected value in the tag based on the value.

我在将返回数据从帮助器传递到Template.Rendered函数时遇到问题.

I am having problem passing the return data from the helpers into the Template.Rendered function.

有什么办法吗?

助手

Template.studentSetting.helpers({
  values: function(){
    return Basics.findOne({userId:Meteor.userId()});
  }
});

渲染功能

Template.studentSetting.rendered = function(){
 //I want to use the "values" helper data here and perform some jquery code based on that?? 
}

推荐答案

根据

According to this post, I would advise doing what mpowaga suggests in the thread and just define the helper outside:

var valuesFunc = function () {
  return Basics.findOne({userId:Meteor.userId()});
};

Template.studentSetting.helpers({
  values: valuesFunc
});

Template.studentSetting.onRendered(function(){
  var values = valuesFunc();
});

这篇关于Meteorjs-将数据上下文传递给模板渲染函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆