考虑到这个要求。
在您发布新帖子之前,在编辑时,有一个预览面板会在您输入时呈现您的帖子内容。
因为它不是一个真正的帖子,我们只希望它只会更新(并从中检索内容)本地 mongodb 并且不希望这个帖子将被同步到服务器。如何实施?
我在模板中试过这个
Template.newPost.events
'keyup .post-content' : (event, templ)->
event.preventDefault()
Deps.nonreactive ->
Post.update({_id: post_id}, {content: event.currentTarget.value })
和这个
Template.newPost.events
'keyup .post-content' : (event, templ)->
event.preventDefault()
Meteor.call 'updatePostContent', post_id, event.currentTarget.value
Meteor.methods
updatePostContent: (postId, value)->
if (this.isSimulation)
Post.update({_id: postId}, {content: value })
else
this.stop()
以上所有都没有效果。
对不起我糟糕的英语。