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

Implementing the initialize method


In this method, we will load the JSON from the server and display the album names in the left panel. Write the following code inside the initialize method to get the JSON from the server:

$.getJSON( "albums.json", function(data) 
{
  albums.jsonAlbums = data;
  albums.fillAlbumNames();
  albums.addEventHandlers();
});

Here we are using jQuery's getJSON method to fetch JSON from the server. We have specified albums.json as the URL and a success handler when a response is received. In success event handler, response is received in a variable data that we place in property jsonAlbums.

Next, we call the methods fillAlbumNames and addEventHandlers of the albums object.