gpt4 book ai didi

mongodb - meteor :从 mongodb 渲染事物后应用函数

转载 作者:可可西里 更新时间:2023-11-01 10:32:58 26 4
gpt4 key购买 nike

我正在使用 sage cell 将 html 转换为数学内容

Template.home.rendered = function(){
\\ apply sagecell and mathjax
}

但是,呈现的内容来自 mongo,因此有时会在应用 sage 单元格后加载它。我可以做这样的事情

Template.home.rendered = function(){
Deps.autorun(function(){
if (Content.findOne({_id: ...})){
\\ apply sagecell and mathjax
}
});
}

它好多了,但仍然不能一直工作。我可以使用其他方法来检测内容是否已完全呈现吗?

最佳答案

用新的回复编辑:

<template name='pendingAnswer'>
The answer to your question, coming back whenever, is:
{{>answer}}
</template>

<template name='answer'>
{{fromSage}}
</template>

Template.answer.helpers({
fromSage: function () {
Session.get('fromSage');
}
});

Invoked whenever - from a button, from navigating to the page, on blur...
function GetAnswerFromSage(data) {
callHTTP(website,data, callbackFromSage)
}

function callbackFromSage(err, data) {
if (err) then log(err);
Session.set('fromSage', data);
}

早些时候:尝试在检索 mongo 时进行转换: From Meteor Doc

// An Animal class that takes a document in its constructor
Animal = function (doc) {
_.extend(this, doc);
};
_.extend(Animal.prototype, {
makeNoise: function () {
console.log(this.sound);
}
});

// Define a Collection that uses Animal as its document
Animals = new Meteor.Collection("Animals", {
transform: function (doc) { return new Animal(doc); }
});

// Create an Animal and call its makeNoise method
Animals.insert({name: "raptor", sound: "roar"});
Animals.findOne({name: "raptor"}).makeNoise(); // prints "roar"

关于mongodb - meteor :从 mongodb 渲染事物后应用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18517050/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com