HTML:
AVPlayerItemPlaybackStalledNotification
JS:
<body>
<div class="container">
<header>
<h1 style="color: red;">Meteor & Parse DB Demo</h1>
</header>
{{>header}}
</div>
</body>
<template name="header">
{{#each alphabets}}
<div class="alphabets">{{this}}</div>
{{/each}}
数据来自数据库,但问题是在数据到达之前加载了模板:
在Parse.initialize("appid", "jsid");
var list_item=Parse.Object.extend("className");
var query=new Parse.Query(list_item);
var list=[];
if (Meteor.isClient) {
query.find({
success:function(o){
for (var i = 0; i < o.length; i++) {
var object = o[i];
list.push(object.get('name'));
console.log(list);
}
return list;
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
Template.header.alphabets = function() {
return list;
};
}
</template>
被称为之前调用 template.headed.alphabet
答案 0 :(得分:2)
使您的列表成为客户端集合,然后它将被激活并更新
$('#teacherProfileLink').on('click', function() {
//load teacher profile
var options = {
url: '/Profile/LoadTeacherProfile',
type: "post",
data: {}
};
$.ajax(options).done(function(data) {
$("#profileSection").html(data);
reparseform();
$("#teacherSubmit").submit(function(event) {
event.preventDefault();
submitTeacherForm();
});
$(document).on('submit', '#teacherSubmit', function(event) {
event.preventDefault();
submitTeacherForm();
});
}).fail(function(jqXHR, textStatus) {
$('#errorHomePage').show().fadeOut(8000).text('Error Calling Server -' + textStatus);
});
然后执行list = new Mongo.Collection(null);
list.insert(object.get('name'))
答案 1 :(得分:1)
以下代码对我有用,我发布此内容,以便其他人可以参考。
HTML:
<body>
<div class="container">
<header>
<h1 style="color: red;">Meteor & Parse DB Demo</h1>
</header>
{{>header}}
</div>
</body>
<template name="header">
{{#each alphabets}}
<div class="alphabets">{{this.name}}</div>
{{/each}}
JS:
Parse.initialize("appid", "jsid");
var list_item=Parse.Object.extend("className");
var query=new Parse.Query(list_item);
var list=[];
if (Meteor.isClient) {
query.find({
success:function(o){
for (var i = 0; i < o.length; i++) {
var object = o[i];
list.push({name:object.get('name')});
console.log(list);
}
return list;
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
Template.header.alphabets = function() {
return list;
};
}
</template>