0
我的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可能是沒有過錯的,因爲刪除工作得很好:
Posts.remove(currentPostId);
所以postProperties對象必須是:
Object {url: "https://github.com/DiscoverMeteor/Microscope", title: "Random Title"}
帖子有一個URL,標題和信息。我有一個.deny()方法的消息,所以我沒有更新。
任何洞察我做錯了什麼?
謝謝你的時間。
'currentPostId'和'this.currentPostId'的值是什麼? – Xyand
this.currentPostId是'未定義的',currentPostId在這種情況下是'wHtYDGjRgbWMYnzMy'。所以我不明白爲什麼currentPostId失敗,而this.currentPostId沒有。 – storedope
'this.currentPostId'不會失敗,因爲沒有這樣的記錄要更新。嘗試使用'Posts.update({_ id:currentPostId},....)' – Xyand