流星助手没有更新

时间:2015-08-18 14:30:02

标签: meteor

Meteor不更新辅助函数。它返回vales但不更新。

Template.recrutersubscription.helpers({
    renderskills: function ()
    {
        console.log(">>>>>>>>>>skilldropdown");
        console.log(Session.get('skilldropdown'));

        return Session.get('skilldropdown');
    }
});

这是我的Html代码

<select id="example-multiple-requiredskill" multiple="multiple">
  <optgroup label="Skills">
    {{{renderskills}}}
  </optgroup>
</select>

1 个答案:

答案 0 :(得分:0)

您确定正确使用无功变量吗?这些数据来自哪里?

请务必遵循以下路径:

var reactiveWhatever = new ReactiveVar({});

template.onCustomCreated = function() {
  return reactiveWhatever.set({
    whatever: true
  });
};

Template.recrutersubscription.helpers(
renderskills: function ()
    {
        console.log(">>>>>>>>>>skilldropdown");
        console.log(Session.get('skilldropdown'));

        return reactiveWhatever.get('skilldropdown');
    }
);

然后在HTML

<select id="example-multiple-requiredskill" multiple="multiple">
  <optgroup label="Skills">
    {{{renderskills}}}
  </optgroup>
</select>