【发布时间】:2015-09-07 02:30:27
【问题描述】:
我正在尝试使用 Meteor 的 Blaze.toHTMLWithData(template, data)(如 Blaze.toHTMLWithData(Template.roomIlanSpecsTemplate, data))来更新我的着名.js 表面的 content,并在函数中使用自定义模板在著名的 surface 内创建著名的 view。我想根据返回给其回调的文档类型在 cursorToArray 函数中传递模板。但是我无法在浏览器上呈现页面,即使控制台中没有错误。如果我使用硬编码版本,例如为每个不同的模板使用 createFn 函数,然后使用该函数定义和 cursorToArray 函数,它就可以工作。
我在这里想念什么?
cursorToArray = function(cursor, renderablesArray, template, createFn){
//each callback should decide which createFn to use based on result document, cos each result has a different template so a createFn.
cursor.observe({
addedAt: function(document, atIndex, before) {
renderablesArray.splice(atIndex, 0, createFn(document, template));//createRoomIlanView, createRoomRenterIlanView, createFriendLookupIlanView
},
changedAt: function(newDocument, oldDocument, atIndex) {
renderablesArray[atIndex] = createFn(newDocument, template);
},
});
}
cursorToArray(Ilans.find(), ilanViews, Template.roomIlanSpecsTemplate, createIlanView);
部分 createFn 定义:
function createIlanView(data, template){
var ilanSpecsSurface = new Surface({
content: Blaze.toHTMLWithData(template, data),
properties: {
fontSize: "14px"
}
});
return ilanSpecsSurface;
}
【问题讨论】:
-
在哪里将新的
Surface添加到FamousEngine的上下文中 -
我已经相应地编辑了标签。
-
实际创建...函数创建一个famo.us
view。 adn 添加了一些带有modifiers和surfaces的分支。上面的表面是这些支架尖端的表面之一,源于view。 -
这个视图用于填充一个数组,它作为我在 headerfooterlayout 的内容部分中使用的滚动视图的序列。
-
我认为问题在于在表面的内容中传递
Blaze函数调用的参数。如果它像我在 Q 中所说的那样是硬编码的,它就可以工作;Blaze.toHTMLWithData(Template.roomIlanSpecsTemplate, data)。但我想简化它。
标签: meteor famo.us meteor-blaze