Meteor:更改子模板而不更改父模板 [英] Meteor: Changing a subtemplate without changing parent template

查看:41
本文介绍了Meteor:更改子模板而不更改父模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有以下模板结构

 <template name="A">
            {{> B}}
            {{> C}}
    </template>

如果没有模板 A 重新渲染,我如何在 C 发生变化时更新它?

How can I have C update when it changes without having Template A re-render?

我试过{{#isolate}}{{>C}}{{/isolate}} 但这不起作用,并且使用恒定区域也不完全正确,因为这不是恒定区域.

I've tried {{#isolate}}{{> C}}{{/isolate}} but this doesn't work and using a constant region isn't quite right either as this isn't a constant region.

推荐答案

从 Meteor 0.7.0.1 开始,重新渲染子模板会导致父模板重新渲染,但不会导致 兄弟 模板重新渲染.隔离的工作方式相同.

As of Meteor 0.7.0.1, re-rendering a sub-template causes the parent to re-render but not sibling templates. Isolate works the same way.

我整理了一个简单的例子,你可以在这里玩:

I put together a simple example of this that you can play with here:

https://github.com/alanning/meteor-subtemplate-isolate-test

请记住,此行为可能会随着即将发布的 Meteor UI 版本而改变,为 Meteor 1.0 做准备.

Keep in mind that this behavior may change with the upcoming release of Meteor UI in preparation for Meteor 1.0.

这篇关于Meteor:更改子模板而不更改父模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆