Skip to content

Instantly share code, notes, and snippets.

@phsacramento
Created June 4, 2014 17:41
Show Gist options
  • Save phsacramento/b7ad28f578b768a16d47 to your computer and use it in GitHub Desktop.
Save phsacramento/b7ad28f578b768a16d47 to your computer and use it in GitHub Desktop.
Function Value
getPostCategory = function(post_id) {
$.getJSON( '/noticias/mobile/' + post_id + '/category', function( data ) {
var returnedObject = new Object();
returnedObject.name = data.name;
returnedObject.slug = data.slug;
console.log(returnedObject);
});
}
function getPosts(url, page, template) {
moment.lang("pt-br");
$.getJSON( url + page, function( data ) {
$.each( data, function(key, value) {
var category = getPostCategory(value.slug);
console.log(category)
$.tmpl(template, {title: value.title, slug: value.slug, time_ago: moment(value.publish_at).startOf('hour').fromNow() }).appendTo(".lasts-list-mobile");
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment