Getting the initial feeds
In this task we'll focus on getting the initial set of data in order to create the page when it first loads. We need to write our code so that the function for getting the first page of data is reusable for any page of data so that we can make use of it later on in the project.
Prepare for Lift Off
We can use the standard document ready
shortcut provided by jQuery, just like we have in a number of previous projects. We can get ready by adding the following code to the infinite-scroller.js
file that we create earlier:
$(function () { //rest of our code will go here... });
Engage Thrusters
First of all we can add the code that retrieves the data from YouTube. Replace the comment in the preceding snippet of code with the following:
var data = {}, startIndex = 1; var getUser = function () { return $.getJSON("http://gdata.youtube.com/feeds/api/users/tedtalksdirector?callback=?", { v: 2, alt: "json" }, function (user) { data.userdata...