0
我正在使用流星的博客上工作,我已經進入了搜索部分:現在我想根據搜索條件更改數據到模板變量。到目前爲止,我不知道如何使模板中要呈現的數據重新排序。流星模板查詢更改,如何更改數據庫中的內容?
這是我現在有: HTML
<template name="posts">
{{#each post}}
<div class = "postWrapper">
<p>{{postTitle}} - <small><em>{{userName}}<em></small></p>
<p><small>{{postDate}}</small><p>
<div class="postText">{{safe 'postText'}}</div>
<br/>
</div>
{{/each}}
</template>
的Javascript
Template.posts.post = function(){
return TestPosts.find({}, {sort: {timeStamp: -1}, limit: 100});
}
如何改變Template.posts.post查詢,以便它按其他財產以後比時間戳。我對Template.posts.post查詢所做的任何更改在事件被觸發時都沒有任何結果。
Template.searchForm.events = {
"click .cancelBtn": function(){
$("#lightbox-container, #searchForm, #postForm").hide();
},
"click #searchBtn": function(){
var reply = TestPosts.find({}, {sort: {timeStamp: 1}});
//what do I need here to be able to change the posts returned
//to the template?
}
}
我試圖使用meteor.render,但它什麼也沒做。任何指導都會很棒。
我從來沒有這樣想過呢,這改變了很多。感謝您的時間。 –