Javascript Meteor.js模板在变量赋值后不更新

Javascript Meteor.js模板在变量赋值后不更新,javascript,html,templates,dom,meteor,Javascript,Html,Templates,Dom,Meteor,我正在用Meteor构建一个免费的电视跟踪应用程序,一路上我好像撞到了墙。我的模板的一部分包含以下内容: <template name="results"> <div class="row"> <div class="span6 offset6"> <h4>Search Results</h4> <ul> {{#each series}}

我正在用Meteor构建一个免费的电视跟踪应用程序,一路上我好像撞到了墙。我的模板的一部分包含以下内容:

<template name="results">
  <div class="row">
      <div class="span6 offset6">
        <h4>Search Results</h4>
          <ul>
            {{#each series}}
            <li><a href="http://thetvdb.com/?tab=episode&seriesid{{tvdbseriesid}}&lid={{tvdblid}}">{{seriesname}}</li>
            {{/each}}
          </ul>
      </div>
    </div>
</template>
“queryshow”服务器方法只是一个集合查询方法,它返回一个包含模板所需数据的对象

但问题是:浏览器窗口中没有反映更改。我似乎不明白为什么,因为下面显示的console.log(Template.results())调用返回了我期望的正确html


我该如何解决这个问题?我试着查看Meteor的文档,但似乎找不到一个强制重新呈现模板的函数。任何帮助都将不胜感激

Template.results.series
应该是一个返回序列的函数,而不是直接设置为要使用的序列。这样,当Meteor运行函数获取序列时,它可以注册函数所依赖的内容,然后在任何依赖项更改时重新运行函数

注册信息依赖项的最简单方法是使用
会话
对象。因此,您的代码看起来像:

Template.results.series = function () { return Session.get('resultsSeries'); }

Meteor.call('queryshow', query, function (err, res) {
  // handle the error if it's there
  // ...
  // Then set the session variable, which will re-run anything that depends on it.
  Session.set('resultsSeries', res)
}

顺便说一下,这里有完整的代码:嘿,非常感谢!接下来的一个问题是,如果我使用不同的变量而不是会话变量,如何实现相同的效果?这样,当它更改时,它将重新运行附加到它的任何函数。谢谢
Template.results.series = function () { return Session.get('resultsSeries'); }

Meteor.call('queryshow', query, function (err, res) {
  // handle the error if it's there
  // ...
  // Then set the session variable, which will re-run anything that depends on it.
  Session.set('resultsSeries', res)
}