I've been trying for a while to get this to work, but I can't find a solution that works the way I need.
I'm using zepto.js and what I need to do is get a list of posts from a feed and loop through them. I've got it all working fine apart from posts which don't have a thumbnail. The way I am passing the articles over leaves an empty img tag if the thumbnail is not present.
Here is my code:
function get_articles(feed) {
$.getJSON(feed, function(data) {
$.each(data.articles, function(i, field) {
articles += "<li class='article' id='article-"+field.id+"'><a href='story.html? aid="+field.id+"'><img src='"+field.thumb+"' class='thumb' /><h3 class='headline'>"+field.headline+"</h3></a></li>"
})
$("ul#channel").html(articles)
})
}
I have tried other methods but I can't seem to find one that doesn't loop the ul or pass multiple loops into one li.
I know I'm probably being stupid, but I've hit a wall. Any pointers will be much appreciated.