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 to the backend.
If you stop and think a bit about how the comments look, you will notice that they are similar to the regular user...