May 2015
Beginner
220 pages
4h 16m
English
The users of our social network should be able to see a Like button. By clicking on it, they will send a request to the API and our task is to count these clicks. Of course, only one click per user is allowed. As in the previous section, we will start by updating the user interface. Let's add another button next to the Share one in the following way:
// frontend/tpl/home.html
<input type="button" value="Like" on-click="like:{{posts[index].id}}" />
{{#if !posts[index].ownPost}}
<input type="button" value="Share" on-click="share:{{posts[index].id}}" />
{{/if}}The new button dispatches a like event, and we will again pass the ID of the post. It is actually similar to the share event. Also, the liking action ...
Read now
Unlock full access