我知道我可以通过if ontheschoolwifi:
Keep running the program
else:
close the program because im not at school and wont need it
获得单个模板实例。但是如何找到Blaze.getView(node)
的所有实例?
答案 0 :(得分:4)
如果我们从Crockford借用walkTheDOM,我们可以将其放入浏览器控制台并在任何页面上找到所有模板实例
function findAllTemplateInstances(templateName){
function walkTheDOM(node, func) {
func(node);
node = node.firstChild;
while (node) {
walkTheDOM(node, func);
node = node.nextSibling;
}
}
var instances = [];
walkTheDOM(document.body, function(node) {
try{
if (Blaze.getView(node).name === templateName){
instances.push(Blaze.getView(node).templateInstance());
}
} catch(err){
}
});
return _.uniq(instances)
}