How to put a reactive Template inside of a Surface in famo.us/Meteor

被刻印的时光 ゝ 提交于 2019-12-13 02:13:26

问题


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).

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]);

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?


回答1:


one possible answer is to use Famodev

var ReactiveTemplate = famodev.ReactiveTemplate;

var reactive = new ReactiveTemplate({
  template: Template.mytemplate,
  data: Collection.find().fetch(),
  properties: {
  }
});

Maybe it will be useful in some way http://github.com/dcsan/moflow



来源:https://stackoverflow.com/questions/30053848/how-to-put-a-reactive-template-inside-of-a-surface-in-famo-us-meteor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!