Getting comments for a post

We have already displayed the posts and a link to view comments with each post. Each of these links has a CSS class named viewComments. In the init method, we have defined an event handler for the click event on this selector. This event handler calls the method getJSONFromAPI with two arguments. The first argument is the set of string comments that will let getJSONFromAPI know that the API request has to be made for comments. The second parameter is the comments id for that particular post, which we assigned using the data-commentsid attribute. The event handler for viewComments gets this value and passes it as a second argument to getJSONFromAPI. We have already defined and discussed the working of getJSONFromAPI ...

Get Mastering jQuery UI 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.