2016-06-29 33 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 template;

<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> 

,然後在你的js文件:

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

感謝help.It原來,評論是不可見的,因爲我刪除自動發佈。還是非常感謝幫助。 –