【问题标题】:Router only render certain templates路由器只渲染某些模板
【发布时间】:2014-03-23 00:01:05
【问题描述】:

我有一个包含 2 个容器 1)productView 和 2)calendarView 的布局。我的路由器配置如下:

this.route('productDetail', {
    layout: 'main',
    path: '/products/:_id',
    waitnOn: function(){...},
    data: function(){...},
    yieldTemplates: {
        'calendarView: { to: calendar }
    }
});

我现在希望在路线更改时(例如从“products/1”更改为“products/2”)仅重新渲染 productView 而 calendarView 什么都不做。至于现在,每次调用“productDetail/:id”路由时,都会调用“calendarView”函数“Template.calendarView.rendered”并重新渲染模板。我的“主要”模板如下所示:

<template name="main">
    <div>
        {{yield}}
    </div>
    <div>
        {{yield 'calendar'}}
    </div>
</template>

有没有办法告诉路由器只渲染某些模板?还是有更好的解决方案? 非常感谢任何帮助。

【问题讨论】:

标签: meteor iron-router


【解决方案1】:

您将路由器用于日历视图有什么原因吗? 我认为一种解决方案可能是不将路由器用于日历视图

<template name="main">
    <div>
        {{yield}}
    </div>
    <div>
        {{>calendar}}
    </div>
</template>

【讨论】:

  • 谢谢,这是一个很好的观点,但问题仍然存在。它仍然会重新渲染两个模板...
  • 您是否检查过您的日历模板读取的会话变量都不是由您的产品模板重新呈现所涉及的代码设置的?
  • 另一个好点。但与此同时,我使用了一个非常简单的测试设置,没有依赖项,也没有 Session 变量,并且体验到了相同的行为。
猜你喜欢
  • 2015-12-24
  • 2015-12-30
  • 2014-12-14
  • 2015-05-24
  • 2017-09-30
  • 1970-01-01
  • 2015-02-15
  • 1970-01-01
  • 2016-01-16
相关资源
最近更新 更多