Book Image

Mastering jQuery UI

By : Vijay Joshi
Book Image

Mastering jQuery UI

By: Vijay Joshi

Overview of this book

Table of Contents (19 chapters)
Mastering jQuery UI
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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. This method will request the API for comments and will call the displayComments method with the API response as an argument. Since we are going to display the comments in a dialog, the event handler for the viewComments selector opens the dialog box...