[英]Meteor.js: what object does {$set: {…} } get?
我的Posts.update()似乎有問題; 方法。
var postProperties = {
url: $(e.target).find('[name=url]').val(),
title: $(e.target).find('[name=title]').val()
}
Posts.update(currentPostId, {$set: postProperties}, function(error){
if (error) {
// display the error to the user
alert(error.reason);
}
else {
Meteor.Router.to('postPage', currentPostId);
}
});
currentPostId可能沒有錯,因為remove可以正常工作:
Posts.remove(currentPostId);
因此,postProperties對象必須為:
Object {url: "https://github.com/DiscoverMeteor/Microscope", title: "Random Title"}
帖子包含網址,標題和消息。 我有一個.deny()方法來處理消息,所以我沒有更新它。
對我在做什么錯有任何見解嗎?
感謝您的時間。
我看了看我的航站樓,所以有一個
Exception while invoking method '/posts/update' ReferenceError: alert is not defined
問題是被遺忘的alert(); 在Posts.deny();中 方法。 從現在開始,我警告的不是Javascript而是DOM(?)。 刪除alert()之后,一切都會按預期進行。
上面的代碼中的alert()(Posts.update();)之所以有效,是因為它位於
Template.postEdit.events({...});
因此,處理DOM事件,其中alert(); 效果很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.