Skip to content

Instantly share code, notes, and snippets.

@elyseholladay
Created July 15, 2014 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elyseholladay/e0de193f23505440a811 to your computer and use it in GitHub Desktop.
Save elyseholladay/e0de193f23505440a811 to your computer and use it in GitHub Desktop.
$(document).ready(function(){
var animals = [];
$.getJSON( "https://mks-frontend-gallery.herokuapp.com/", function( json ) {
for (var i in json) {
$(".gallery").append("<div class='large-4 small-6 columns " + json[i].animals.join(" ") + "'><img src=" + json[i].url + "></div>");
}
var ids = [];
$.each( json, function ( key, val ) {
for (var x = 0; x < val.animals.length; x++) {
ids.push(
val.animals[x]
);
}
$.unique(ids);
});
for (i in ids) {
$(".filters").append("<div class='filter-button individual button active' id='" + ids[i] + "'>" + ids[i]+ "</div>");
}
console.log(ids);
}).done(function(){
console.log("done")
$('.filter-button').click(function(){
$(this).toggleClass("active");
$("." + this.id).fadeToggle(1000, "swing", function(){console.log("fade is done")});
});
}).fail(function(){
console.log("fail")
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment