Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor:模板助手在页面背面开火_Meteor - Fatal编程技术网

Meteor:模板助手在页面背面开火

Meteor:模板助手在页面背面开火,meteor,Meteor,我有一个“userLayout”模板的助手,我在其中定义了一个当前用户函数。当我导航到模板时,它可以正常工作(我在路由中使用订阅流路由器)。但是,当我在浏览器中按“后退”时,辅助对象将再次激发 为什么当我按下“后退”时,助手会为我要离开的模板激活 我的一个有问题的助手的代码在这里-我怀疑“上下文”属性: // Return a specific user findUser: function(context) { var id = context.user; return Pot

我有一个“userLayout”模板的助手,我在其中定义了一个当前用户函数。当我导航到模板时,它可以正常工作(我在路由中使用订阅流路由器)。但是,当我在浏览器中按“后退”时,辅助对象将再次激发

为什么当我按下“后退”时,助手会为我要离开的模板激活

我的一个有问题的助手的代码在这里-我怀疑“上下文”属性:

// Return a specific user
findUser: function(context) {
    var id = context.user;
    return Potential_users.find({_id: id});
}
编辑

视图模板本身如下所示:

<template name="userLayoutView">
    {{#each findUser context}}
       ...
    {{/each}}
</template>

{{{#每个findUser上下文}
...
{{/每个}}
该视图被动态调用,如下所示:

<template name="userLayout">
    <div class="row">
        <div class="col-xs-12">
            {{#if currentUser context}}
                {{> userLayoutEditCreate context=context}}
            {{else}}
                {{> userLayoutView context=context}}
            {{/if}}
        </div>
    </div>
</template>

{{{#如果当前用户上下文}
{{>userLayoutEditCreate context=context}
{{else}
{{>userLayoutView上下文=上下文}
{{/if}

您的模板代码是什么样子的?我已经编辑了代码。顺便说一句,从现在的阅读来看,我似乎已经覆盖了currentUser helper。。。那很糟糕吗?是的,你应该给它改名。你再开枪是什么意思?你怎么知道?