2016-06-29 10 views
0

どういうわけか特定の投稿にコメントを追加できません。コメントはmongoデータベースに挿入されていません。meteorjsの投稿にコメントを追加できません

コメントページのHTMLコードがある:

<template name="comments"> 
    <h2><b>{{name}}</b></h2> 

    {{> addComment}} 
    <ul> 
     {{#each comment}} 
      <li>{{comment}}</li> 
     {{/each}} 
    </ul> 
</template> 


<template name='addComment'> 
<input type='text' placeholder='Add comment here' name='comment' id ='mycomment'> 
<button class="btn btn" type="button" id='btn'>Comment</button> 
</template> 

ここ{{名前}}はコメントがなされた前記ポストの名前を指します。 私を助けてください。おかげです。

答えて

1

addCommentテンプレートにフォーム要素を配置する必要があります。

あなたのjsファイルで
<template name='addComment'> 
    <form class="add-Comment"> 
    <input type='text' placeholder='Add comment here' name='comment' id ='mycomment'> 
    <button class="btn btn" type="button" id='btn'>Comment</button> 
    </form> 
    </template> 

、その後:help.Itため

Template.addComment.events({ 
    'submit .add-Comment': function(event){ 
    ... 
    return false; 
    } 
}); 
+0

おかげで、私はautopublishを取り除くため、コメントは見えなかったことが判明。まだ助けてくれてありがとう。 –

関連する問題