如何在famo.us/Meteor中将反应式模板放置在Surface的内部 [英] How to put a reactive Template inside of a Surface in famo.us/Meteor
问题描述
我已经阅读了几篇有关此问题的文章,但没有什么能以最新的方式真正回答我的问题(即UI.insert已贬值).
I've read several posts on this but nothing that would really answer my question in an up-to-date way (i.e. UI.insert is depreciated).
因此,以反应方式将模板插入/渲染到Surface中的最佳方法是什么,这意味着,不仅一个数据对象(renderWithData),而且Template.helpers中定义的内容也应进行反应式更新.到目前为止,代码已尝试:
So what's the best way of inserting/rendering a Template into a Surface reactively, meaning, not only one data object (renderWithData), but whatever is defined in the Template.helpers should also be updated reactively. Code tried so far:
var div = document.createElement('div');
//UI.insert(UI.render(function() { return Template.hello; }), div);
surface = new famous.core.Surface({
//content: Blaze.toHTML(function() { return Template.hello; }),
//content: div,
content: '<div class="hell"></div>',
size: [window.innerWidth, window.innerHeight],
properties: {...}
});
Blaze.render(function() { return Template.hello}, $('.hell')[0]);
这些是我尝试过的3种不同方法.首先将UI.insert插入,但是无法识别车把风格的助手.其次,对于HTML,即使我将所有内容都放入Tracker.autorun(),也没有反应.第三,Blaze.render(...)根本不起作用.
These are 3 different approaches I've tried. First UI.insert inserts it, but handlebars-style Helpers are not recognized. Second, toHTML, no reactivity, even when I put everything into a Tracker.autorun(). Third, Blaze.render(...), doesn't work at all.
对此有简单的解决方法吗?
Is there an easy solution to this?
推荐答案
一个可能的答案是使用 Famodev
one possible answer is to use Famodev
var ReactiveTemplate = famodev.ReactiveTemplate;
var reactive = new ReactiveTemplate({
template: Template.mytemplate,
data: Collection.find().fetch(),
properties: {
}
});
也许它会以某种方式有用 http://github.com/dcsan/moflow
Maybe it will be useful in some way http://github.com/dcsan/moflow
这篇关于如何在famo.us/Meteor中将反应式模板放置在Surface的内部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!