Posting a comment to a page

Before reaching the part where we send and process an HTTP request, we have to provide a user interface to create a comment. We will add a form just below the title and description of the page in frontend/tpl/pages.html:

<form enctype="multipart/form-data" method="post">
  <h3>Add a comment for this page</h3>
  {{#if error && error != ''}}
    <div class="error">{{error}}</div>
  {{/if}}
  {{#if success && success != ''}}
    <div class="success">{{{success}}}</div>
  {{/if}}
  <label for="text">Text</label>
  <textarea value="{{text}}"></textarea>
  <input type="button" value="Post" on-click="add-comment" />
</form>

The event that is dispatched after clicking on the button is add-comment. The Pages controller should handle it and fire a request ...

Get Node.js By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.