I am working on a twitter like app for class. I am trying to create a new $tweet for each loop iteration and append each &tweet into my $feed container. However, when run, only the first tweet in the array is shown. My hypothesis is that only one $tweet is being created and appended and that each iteration simply overwrites it. Heres my sample code.
var renderfeed = function() {
$feed.empty();
var index = streams.home.length - 1;
while (index >= 0) {
// for (var i = 0; i < index + 1; i++) {
var tweet = streams.home[index];
var $tweet = $('<div class="tweet"></div>');
$tweet.appendTo($feed);
console.log(tweet);
console.log(streams.home);
console.log($tweet);
//assingning values to variable to be pushed into $tweet div, icons already established
$userName.text('@' + tweet.user);
$profilePhoto.attr("src", tweet.profilePhotoURL);
$message.text(tweet.message);
$timeStamp.text(tweet.created_at);
//appending child elements to $tweet
$profilePhoto.appendTo($tweet);
$userName.appendTo($tweet);
$message.appendTo($tweet);
$timeStamp.appendTo($tweet);
$like.appendTo($tweet);
$retweet.appendTo($tweet);
$comment.appendTo($tweet);
$share.appendTo($tweet);
index -= 1;
}
};