meteor.js iron-router:防止静态模板重新渲染和毛刺? [英] meteor.js iron-router: prevent static template re-render and glitching?
问题描述
我有一个全局模板:
<template name="layout">
{{> header}}
{{> primaryNav}}
{{yield 'banner'}}
{{yield}}
{{> footer}}
{{> deleteConfirmModal }}
<span class="responsive-state"></span>
</template>
以及当我做路线
@route 'blog',
path: '/blog/'
一切正常,花花公子.我可以在标题链接和导航链接之间来回单击,而不会出现故障.但是,如果我添加数据上下文:
Everything works dandy. I can click back and forth through my header links and nav links with no glitching. But if I add a data context:
@route 'blog',
path: '/blog/'
data: ->
blogPosts: BlogPosts.find({}, {date: -1, time: -1})
在提供数据上下文时,每当我导航到提供数据上下文的路径时,所有嵌套在布局模板中的模板都会重新渲染,这会由于样式类被擦除而导致故障更换.如果我路由到不需要(也未提供)数据上下文的任何其他路径,则静态模板不会重新呈现.
When providing a data context, whenever I navigate to and away from a route in which a data context is provided all the templates nested in the layout template appear to re-render, causing glitches due to style classes that get wiped and then replaced. If I route to any other paths that do not require (and are not provided) a data context, the static templates do not re-render.
在为特定路由提供数据上下文时,是否可以防止某些静态模板重新呈现?
Is there a way to prevent certain static templates from re-rendering when providing a data context for a specific route?
推荐答案
在流星处于当前状态的情况下,您可能应该依靠渲染破坏大多数内容.
With Meteor in the current state- you should probably rely on renders breaking most stuff.
对于铁路由器-data
存储在ReactiveVar
中,并确保对data
的任何更改都会导致layoutTemplate
重新呈现(这可能是过分简化的解释)
As for iron-router - the data
is stored in a ReactiveVar
, and it ensures that any changes to data
cause the layoutTemplate
to re-render (this might be an over-simplified interpretation).
您也许可以:
- 删除添加时具有动画效果的样式
- 尝试使用保护区将元素保持完整. (注意:除元素引用外,它不保留任何内容,所有值/属性均会根据模板生成的元素进行重置)
- 等待流星1.0,或使用新的模板渲染预览之一来修补" DOM,而不是重新插入渲染上的每个元素.
这篇关于meteor.js iron-router:防止静态模板重新渲染和毛刺?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!