所以我使用 JSON 和 jQuery 将新活动拉入活动提要。我正在寻找最新的条目来“下推”以前的最新条目。非常感谢任何提示:D
提要的 HTML 结构:
<div id="activityspot">
<div class="entry template">
<div class="actProfilePic"></div>
<div class="actMessage"></div>
<div class="actName"></div>
<div class="actContent"></div>
<div class="actImage"></div>
</div>
</div>
jQuery:
for (var j = 0; j < jsonData.items.length; j++) {
var entryData = jsonData.items[j];
var entry = template.clone();
entry.removeClass("template");
entry.find(".message").text(entryData.statusid);
entry.find(".actName").text(entryData.name);
entry.find(".actContent").text(entryData.content);
//get the users ProfilePic
var profileImg = $("<img />");
profileImg.attr("src", "./img/" +entryData.profilePic);
profileImg.addClass("feed-user-img");
entry.find(".actProfilePic").append(profileImg);
//Get user-uploaded images.
entry.find(".actImage").text(entryData.imageKey);
if (entryData.imageKey != "")
{
var img = $("<img />"); // Create the image element
img.attr("src", "http://spartadev.s3.amazonaws.com/" + entryData.imageKey); // Set src to the s3 url plus the imageKey
entry.find(".actImage").append(img); // Append it to the element where it's supposed to be
}
spot.prepend(entry); //Finish off by prepending the new entry to the top of the feed
}